home *** CD-ROM | disk | FTP | other *** search
/ Your Choice 1 / your choice.zip / your choice / PRGMMING / VISIONIX / VSERU.PAS < prev    next >
Pascal/Delphi Source File  |  1993-12-30  |  125KB  |  5,561 lines

  1. {
  2.  ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix Serial Communictions Unit (VSER)
  5.    Version 0.5
  6.  Copyright 1991,92,93 Visionix
  7.  ALL RIGHTS RESERVED
  8.  
  9.  ────────────────────────────────────────────────────────────────────────────
  10.  
  11.  revision history in reverse chronological order:
  12.  
  13.  Initials  Date      Comment
  14.  
  15.  ────────  ────────  ────────────────────────────────────────────────────────
  16.  
  17.  jrt       12/28/93  Documentation madness!
  18.  
  19.  jrt       12/06/93  Moved wait functions to VSerHu;
  20.  
  21.  jrt       12/05/93  Cleaned up, started wait functions.
  22.  
  23.  lpg       03/16/93  Added Source Documentation
  24.  
  25.  mep       02/11/93  Cleaned up code for beta release
  26.  
  27.  jrt       02/08/93  Sync with beta 0.12 release
  28.  
  29.  jrt       11/21/92  Sync with beta 0.08
  30.  
  31.  jrt       09/01/92  First logged revision.
  32.  
  33.  ────────────────────────────────────────────────────────────────────────────
  34. }
  35.  
  36. (*-
  37.  
  38. [TEXT]
  39.  
  40. <Overview>
  41.  
  42. The VSERU unit implements a comprehensive set of functions for serial
  43. communications.
  44.  
  45.  
  46. <Interface>
  47.  
  48. -*)
  49.  
  50.  
  51. Unit VSeru;
  52.  
  53. Interface
  54.  
  55. Uses
  56.  
  57. {$IFDEF VER70}
  58.   Strings,
  59. {$ENDIF}
  60.   VTypesu,
  61.   VSerLu;
  62.  
  63.  
  64. {────────────────────────────────────────────────────────────────────────────}
  65.  
  66. Const
  67.  
  68.   sfct_None       = 0;
  69.   sfct_RtsCts     = 1;
  70.   sfct_XonXoff    = 2;
  71.  
  72.  
  73.   {-----------------}
  74.   { TError Messages }
  75.   {-----------------}
  76.  
  77.   ser_None               = 0;
  78.   ser_NoMemAvail         = 1;
  79.   ser_NoWrite            = 2;
  80.  
  81.  
  82.   {------------------}
  83.   { Status Bit Flags }
  84.   {------------------}
  85.  
  86.   sbf_MSRctsDelta = 0;   { Clear To Send changed                     }
  87.                          { Delta clear to send (not reliable)        }
  88.  
  89.   sbf_MSRdsrDelta = 1;   { Data Set Ready changed                    }
  90.                          { Delta data set ready (not reliable)       }
  91.  
  92.   sbf_MSRriDelta  = 2;   { Ring Indicate changed                     }
  93.                          { Delta data carrier detect (not reliable)  }
  94.  
  95.   sbf_MSRcdDelta  = 3;   { Carrier Detect changed                    }
  96.                          { always set to 1 upon return (DUMMY DCD)   }
  97.  
  98.   sbf_MSRcts      = 4;   { Clear To Send                             }
  99.                          { CTS - DCE sets - do not xmit until true   }
  100.  
  101.   sbf_MSRdsr      = 5;   { Data Set Ready                            }
  102.                          { DSR - modem is ready to be used           }
  103.  
  104.   sbf_MSRri       = 6;   { Ring Indicate                             }
  105.                          { RI - only on during active voltage signal }
  106.  
  107.   sbf_MSRcd       = 7;   { Carrier Detect                            }
  108.                          { DCD - data carrier detect                 }
  109.  
  110.   sbf_LSRRcvReady = 8;   { Received data ready                       }
  111.                          { RDA  - input data is available in buffer  }
  112.  
  113.   sbf_LSROverrun  = 9;   { OverRun error                             }
  114.                          { OVRN - the input buffer has been overrun  }
  115.  
  116.   sbf_LSRParity   = 10;  { Parity error                              }
  117.                          { Reserved (Parity error in BIOS INT 14h)   }
  118.  
  119.   sbf_LSRFrame    = 11;  { Framing error                             }
  120.                          { Reserved (Framing error in BIOS INT 14h)  }
  121.  
  122.   sbf_LSRBreak    = 12;  { Break detected                            }
  123.                          { Reserved (Break detect in BIOS INT 14h)   }
  124.  
  125.   sbf_LSRXhReady  = 13;  { Transmit hold register empty              }
  126.                          { THRE - room is available in output buffer }
  127.  
  128.   sbf_LSRXsReady  = 14;  { Transmit shift register empty             }
  129.                          { TSRE - output buffer is empty             }
  130.  
  131.   sbf_LSRTimeout  = 15;  { Timeout (software implemented).  If true, }
  132.                          { then none of the above 15 bits are valid. }
  133.  
  134.   sbf_DTRReady    = 16;  { Data terminal ready                       }
  135.                          { DTR - used as off-hook.                   }
  136.  
  137.   sbf_RTSReady    = 17;  { Request to send                           }
  138.                          { RTS - DTE sets - use when data to xmit    }
  139.  
  140.  
  141.  
  142. {-----------------------------}
  143. { Serial ReadEx/WriteEx flags }
  144. {-----------------------------}
  145.  
  146. Const
  147.  
  148.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  149.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  150.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  151.   csfImmediate = $02;          { Bypass read/write buffers;              }
  152.  
  153.  
  154.  
  155. Type
  156.  
  157.   TSerHandle = ^TSerChan;
  158.   PSerHandle = ^TSerHandle;
  159.  
  160.   TError     = LONGINT;
  161.  
  162. {────────────────────────────────────────────────────────────────────────────}
  163. {────────────────────────────────────────────────────────────────────────────}
  164.  
  165. {================}
  166. { Serial Channel }
  167. {================}
  168.  
  169.  
  170.  
  171. Function  VSerChanNew(              Flags       : WORD;
  172.                                     Proc        : TSerDriverProc;
  173.                                     DriverInfo1 : LONGINT;
  174.                                     DriverInfo2 : LONGINT;
  175.                                     DriverInfo3 : LONGINT;
  176.                                 Var ChanHandle  : TSerHandle    ) : TError;
  177.  
  178. Procedure VSerGetCaps(              ChanHandle  : TSerHandle;
  179.                                     Caps        : PSerCaps    );
  180.  
  181.  
  182. Procedure VSerChanDispose(          ChanHandle  : TSerHandle    ) ;
  183.  
  184.  
  185.  
  186. {=======================}
  187. { Serial Channel Driver }
  188. {=======================}
  189.  
  190.  
  191. Function  VSerDriverNew(            Chan        : TSerHandle;
  192.                                     Proc        : TSerDriverProc;
  193.                                     DriverInfo1 : LONGINT;
  194.                                     DriverInfo2 : LONGINT;
  195.                                     DriverInfo3 : LONGINT      ) : TError;
  196.  
  197. Procedure VSerDriverDispose(        Handle      : TSerHandle    ) ;
  198.  
  199.  
  200.  
  201.  
  202. Function  VSerChanActivate(         Chan        : TSerHandle;
  203.                                     CommParam   : PCommParam    ) : TError;
  204.  
  205. Function  VSerChanDeactivate(       Chan        : TSerHandle    ) : TError;
  206.  
  207.  
  208.  
  209. {========================}
  210. { Serial Channel Control }
  211. {========================}
  212.  
  213. Function  VSerGetCommParam(         Chan        : TSerHandle;
  214.                                     CommParam   : PCommParam    ) : TError;
  215.  
  216. Function  VSerSetCommParam(         Chan        : TSerHandle;
  217.                                     CommParam   : PCommParam    ) : TError;
  218.  
  219. Function  VSerGetBaud(              Chan        : TSerHandle    ) : LONGINT;
  220.  
  221. Function  VSerGetParity(            Chan        : TSerHandle    ) : CHAR;
  222.  
  223. Function  VSerGetDataBits(          Chan        : TSerHandle    ) : BYTE;
  224.  
  225. Function  VSerGetStopBits(          Chan        : TSerHandle    ) : BYTE;
  226.  
  227. Function  VSerSetBaud(              Chan        : TSerHandle;
  228.                                     BaudRate    : LONGINT       ) : TError;
  229.  
  230. Function  VSerSetParity(            Chan        : TSerHandle;
  231.                                     Parity      : CHAR          ) : TError;
  232.  
  233.  
  234. Function  VSerSetDataBits(          Chan        : TSerHandle;
  235.                                     DataBits    : WORD          ) : TError;
  236.  
  237. Function  VSerSetStopBits(          Chan        : TSerHandle;
  238.                                     StopBits    : WORD          ) : TError;
  239.  
  240.  
  241.  
  242.   {--------------}
  243.   { Flow Control }
  244.    {--------------}
  245.  
  246. Function  VSerGetFlowConType(       Chan        : TSerHandle    ) : INTEGER;
  247.  
  248. Function  VSerSetFlowConType(       Chan        : TSerHandle;
  249.                                     FlowConType : INTEGER       ) : TError;
  250.  
  251. Function  VSerGetFlowConChars(      Chan        : TSerHandle;
  252.                                 Var Startchar   : CHAR;
  253.                                 Var Stopchar    : CHAR          ) : TError;
  254.  
  255. Function  VSerSetFlowConChars(      Chan        : TSerHandle;
  256.                                     Startchar   : CHAR;
  257.                                     Stopchar    : CHAR          ) : TError;
  258.  
  259. Function  VSerTurnSendOn(           Chan        : TSerHandle    ) : TError;
  260.  
  261. Function  VSerTurnSendOff(          Chan        : TSerHandle    ) : TError;
  262.  
  263. Function  VserTurnReceiveOn(        Chan        : TSerHandle    ) : TError;
  264.  
  265. Function  VSerTurnReceiveOff(       Chan        : TSerHandle    ) : TError;
  266.  
  267.  
  268.   {---------------------------}
  269.   { line/modem control/status }
  270.   {---------------------------}
  271.  
  272. Function  VSerGetLineControl(       Chan        : TSerHandle    ) : WORD;
  273.  
  274. Function  VSerGetLineStatus(        Chan        : TSerHandle    ) : WORD;
  275.  
  276. Function  VSerGetModemControl(      Chan        : TSerHandle    ) : WORD;
  277.  
  278. Function  VSerGetModemStatus(       Chan        : TSerHandle    ) : WORD;
  279.  
  280. Function  VSerGetStatus(            Chan        : TSerHandle    ) : LONGINT;
  281.  
  282. Function  VSerGetStatusBit(         Chan        : TSerHandle;
  283.                                     Bit         : BYTE          ) : BOOLEAN;
  284.  
  285. Function  VSerCarrier(              Chan        : TSerHandle    ) : BOOLEAN;
  286.  
  287. Function  VSerRing(                 Chan        : TSerHandle    ) : BOOLEAN;
  288.  
  289. Function  VSerInAvail(              Chan        : TSerHandle    ) : BOOLEAN;
  290.  
  291. Function  VSerInFull(               Chan        : TSerHandle    ) : BOOLEAN;
  292.  
  293. Function  VSerOutReady(             Chan        : TSerHandle    ) : BOOLEAN;
  294.  
  295. Function  VSerOutEmpty(             Chan        : TSerHandle    ) : BOOLEAN;
  296.  
  297.  
  298.   {-------------------}
  299.   { Line/Modem change }
  300.   {-------------------}
  301.  
  302. Function  VSerTurnDTROn(            Chan        : TSerHandle    ) : TError;
  303.  
  304. Function  VSerTurnDTROff(           Chan        : TSerHandle    ) : TError;
  305.  
  306. (*
  307. Function  VSerDropDTR(              Chan        : TSerHandle;
  308.                                     DTLen       : LONGINT       ) : TError;
  309. *)
  310.  
  311. Function  VSerTurnBreakOn(          Chan        : TSerHandle    ) : TError;
  312.  
  313. Function  VSerTurnBreakOff(         Chan        : TSerHandle    ) : TError;
  314.  
  315. Function  VSerBreak(                Chan        : TSerHandle;
  316.                                     BreakLen    : LONGINT       ) : TError;
  317.  
  318. Function  VSerTurnRTSON(            Chan        : TSerHandle    ) : TError;
  319.  
  320. Function  VSerTurnRTSOff(           Chan        : TSerHandle    ) : TError;
  321.  
  322.   {----------------}
  323.   { Buffer Control }
  324.   {----------------}
  325.  
  326. Function  VSerFlushOutBuff(         Chan        : TSerHandle    ) : TError;
  327.  
  328. Function  VSerPurgeOutBuff(         Chan        : TSerHandle    ) : TError;
  329.  
  330. Function  VSerPurgeInBuff(          Chan        : TSerHandle    ) : TError;
  331.  
  332. Function  VSerGetInBuffInfo(        Chan        : TSerHandle;
  333.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  334.  
  335. Function  VSerSetInBuffInfo(        Chan        : TSerHandle;
  336.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  337.  
  338. Function  VSerGetOutBuffInfo(       Chan        : TSerHandle;
  339.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  340.  
  341. Function  VSerSetOutBuffInfo(       Chan        : TSerHandle;
  342.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  343.  
  344.  
  345. Function  VSerGetInAvail(           Chan        : TSerHandle    ) : LONGINT;
  346.  
  347. Function  VSerGetOutFree(           Chan        : TSerHandle    ) : LONGINT;
  348.  
  349.  
  350.  
  351.  
  352.  
  353. {==============}
  354. { Serial Event }
  355. {==============}
  356. (*
  357. Procedure VSerEventProcNew(         Chan        : TSerHandle;
  358.                                     Proc        : TSerEventProc;
  359.                                     EventMask   : WORD;
  360.                                     ProcInfo    : Pointer;
  361.                                 Var ProcHandle  : TSerHandle    ) : TError;
  362.  
  363. Procedure VSerEventProcOff(         ProcHandle  : TSerHandle    );
  364.  
  365. Procedure VSerEventProcOn(          ProcHandle  : TSerHandle    );
  366.  
  367. Procedure VSerEventProcDispose(     ProcHandle  : TSerHandle    );
  368. *)
  369.  
  370.  
  371.  
  372. {====================}
  373. { Serial Channel I/O }
  374. {====================}
  375.  
  376.  
  377. Function  VSerWriteChEx(            Chan        : TSerHandle;
  378.                                     Flags       : WORD;
  379.                                     OutCh       : CHAR;
  380.                                     Timeout100s : LONGINT       ) : TError;
  381.  
  382. Function  VSerWriteBlockEx(         Chan        : TSerHandle;
  383.                                     Flags       : WORD;
  384.                                     BuffSize    : LONGINT;
  385.                                     BuffPtr     : POINTER;
  386.                                     TimeOut100s : LONGINT;
  387.                                 Var XFerCount   : LONGINT      ) : TError;
  388.  
  389. Function  VSerWriteStEx(            Chan        : TSerHandle;
  390.                                     Flags       : WORD;
  391.                                     ST          : STRING;
  392.                                     TimeOut100s : LONGINT;
  393.                                 Var XFerCount   : LONGINT      ) : TError;
  394.  
  395. {$IFDEF VER70}
  396. Function  VSerWritePchEx(           Chan        : TSerHandle;
  397.                                     Flags       : WORD;
  398.                                     Pch         : PChar;
  399.                                     TimeOut100s : LONGINT;
  400.                                 Var XFerCount   : LONGINT     ) : TError;
  401. {$ENDIF}
  402. {---}
  403.  
  404.  
  405. Function  VSerSetWriteTimeout(      Chan        : TSerHandle;
  406.                                     TimeOut100s : LONGINT      ) : TError;
  407.  
  408. Function  VSerSetWriteFlags(        Chan        : TSerHandle;
  409.                                     Flags       : WORD         ) : TError;
  410.  
  411. Function  VSerGetWriteTimeout(      Chan        : TSerHandle   ) : LONGINT;
  412.  
  413. Function  VSerGetWriteFlags(        Chan        : TSerHandle   ) : WORD;
  414.  
  415.  
  416.  
  417. Function  VSerWriteCh(              Chan        : TSerHandle;
  418.                                     OutCh       : CHAR        ) : TError;
  419.  
  420. Function  VSerWriteBlock(           Chan        : TSerHandle;
  421.                                     BuffSize    : LONGINT;
  422.                                     BuffPtr     : POINTER     ) : TError;
  423.  
  424. Function  VSerWriteSt(              Chan        : TSerHandle;
  425.                                     St          : STRING      ) : TError;
  426.  
  427. {$IFDEF VER70}
  428.  
  429. Function  VSerWritePch(             Chan        : TSerHandle;
  430.                                     Pch         : PChar       ) : TError;
  431.  
  432. {$ENDIF}
  433.  
  434. {---}
  435.  
  436. Function  VSerReadChEx(             Chan        : TSerHandle;
  437.                                     Flags       : WORD;
  438.                                 Var InCh        : CHAR;
  439.                                     Timeout100s : LONGINT       ) : TError;
  440.  
  441. Function  VSerReadBlockEx(          Chan        : TSerHandle;
  442.                                     Flags       : WORD;
  443.                                     BuffSize    : LONGINT;
  444.                                     BuffPtr     : POINTER;
  445.                                     TimeOut100s : LONGINT;
  446.                                 Var XFerCount   : LONGINT      ) : TError;
  447.  
  448. Function  VSerReadStEx(             Chan        : TSerHandle;
  449.                                     Flags       : WORD;
  450.                                     STSize      : WORD;
  451.                                 Var ST          : STRING;
  452.                                     TimeOut100s : LONGINT      ) : TError;
  453.  
  454. Function  VSerReadPchEx(            Chan        : TSerHandle;
  455.                                     Flags       : WORD;
  456.                                     PchSize     : LONGINT;
  457.                                     Pch         : PChar;
  458.                                     TimeOut100s : LONGINT      ) : TError;
  459.  
  460. {---}
  461.  
  462. Function  VSerSetReadTimeout(       Chan        : TSerHandle;
  463.                                     TimeOut100s : LONGINT      ) : TError;
  464.  
  465. Function  VSerSetReadFlags(         Chan        : TSerHandle;
  466.                                     Flags       : WORD         ) : TError;
  467.  
  468. Function  VSerGetReadTimeout(       Chan        : TSerHandle   ) : LONGINT;
  469.  
  470. Function  VSerGetReadFlags(         Chan        : TSerHandle   ) : WORD;
  471.  
  472.  
  473.  
  474.  
  475. Function  VSerReadCh(               Chan        : TSerHandle;
  476.                                 Var InCh        : CHAR        ) : TError;
  477.  
  478. Function  VSerReadBlock(            Chan        : TSerHandle;
  479.                                     BuffSize    : LONGINT;
  480.                                     BuffPtr     : POINTER     ) : TError;
  481.  
  482. Function  VSerReadSt(               Chan        : TSerHandle;
  483.                                     STSize      : WORD;
  484.                                 Var St          : STRING      ) : TError;
  485.  
  486.  
  487.  
  488. Function  VSerReadPCh(              Chan        : TSerHandle;
  489.                                     PchSize     : LONGINT;
  490.                                     Pch         : PChar       ) : TError;
  491.  
  492. Function  VSerGetCh(                Chan        : TSerHandle  ) : CHAR;
  493.  
  494. Function  VSerGetStEx(              Chan        : TSerHandle;
  495.                                     MaxBytes    : BYTE        ) : STRING;
  496.  
  497. Function  VSerGetSt(                Chan        : TSerHandle  ) : STRING;
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505. (*
  506. Procedure VSerWriteCh(              Chan        : TSerHandle;
  507.                                     OutCh       : CHAR          );
  508.  
  509.  
  510. Function  VSerWriteChEx(            Chan        : TSerHandle;
  511.                                     OutCh       : CHAR          ) : TError;
  512.  
  513. Function  VSerWriteBlock(           Chan        : TSerHandle;
  514.                                     BuffSize    : LONGINT;
  515.                                     BuffPtr     : Pointer;
  516.                                 Var XFerCount   : LONGINT       ) : TError;
  517.  
  518. Function  VSerWriteSt(              Chan        : TSerHandle;
  519.                                     S           : STRING        ) : TError;
  520.  
  521. Function  VSerReadCh(               Chan        : TSerHandle    ) : CHAR;
  522.  
  523. Function  VSerReadChEx(             Chan        : TSerHandle;
  524.                                 Var Ch          : CHAR          ) : TError;
  525.  
  526. Function  VSerReadBlock(            Chan        : TSerHandle;
  527.                                     BuffSize    : LONGINT;
  528.                                     BuffPtr     : Pointer;
  529.                                 Var XFerCount   : LONGINT       ) : TError;
  530.  
  531. Function  VSerReadSt(               Chan        : TSerHandle;
  532.                                     MaxStSize   : BYTE;
  533.                                 Var St          : STRING        ) : TError;
  534.  
  535. *)
  536.  
  537. Function  VSerPeekCh(               Chan        : TSerHandle;
  538.                                 Var Ch          : CHAR          ) : TError;
  539.  
  540.  
  541. {────────────────────────────────────────────────────────────────────────────}
  542. {────────────────────────────────────────────────────────────────────────────}
  543.  
  544. IMPLEMENTATION
  545.  
  546.  
  547. {────────────────────────────────────────────────────────────────────────────}
  548.  
  549. (*-
  550.  
  551. [FUNCTION]
  552.  
  553. Function  VSerChanNew(              Flags       : WORD;
  554.                                     Proc        : TSerDriverProc;
  555.                                     DriverInfo1 : LONGINT;
  556.                                     DriverInfo2 : LONGINT;
  557.                                     DriverInfo3 : LONGINT;
  558.                                 Var ChanHandle  : TSerHandle    ) : TError;
  559.  
  560. [PARAMETERS]
  561.  
  562. Flags       Channel new flags (0)
  563. Proc        Serial channel driver procedure
  564. DriverInfo1 Information passed to serial channel driver
  565. DriverInfo1 Information passed to serial channel driver
  566. DriverInfo1 Information passed to serial channel driver
  567. Chanhandle  (RETURNS) handle for the new channel
  568.  
  569. [RETURNS]
  570.  
  571. 0 if successfully, otherwise a serial error value.
  572.  
  573. ChanHandle  handle for the new channel.
  574.  
  575. [DESCRIPTION]
  576.  
  577. This function creates a new serial channel.  A serial channel is a link
  578. to a specific serial port on a specific serial driver.
  579.  
  580. Flags are currently 0.
  581.  
  582. Proc is the address of a serial channel driver procedure.  VisionTools
  583. comes with three serial channel driver procedures:
  584.  
  585.   Name             Description                          Unit
  586.   ---------------- ------------------------------------ --------------
  587.  
  588.   FosDriverProc    for FOSSIL drivers                   VFOSU
  589.   UartDriverProc   for direct UART programming          VUARTU
  590.   OS2SerDriverProc for OS/2 serial drivers              VOS2SERU
  591.  
  592. DriverInfo1,2, and 3 are paramaters which are passed to the specified
  593. serial driver procedure.
  594.  
  595. DriverInfo1 is used to specify which port the driver should connect
  596. this new channel two.  Values are typically in the range from 1-8.
  597.  
  598. DriverInfo2 and DriverInfo3 are not currently used by any of the
  599. three VisionTools supplied serial channel driver procedures.
  600.  
  601. [SEE-ALSO]
  602.  
  603. [EXAMPLE]
  604.  
  605.   { To create a new channel attached to port 2 of the FOSSSIL driver }
  606.  
  607.   Error  := VSerChanNew( 0,
  608.                          FosDriverProc,
  609.                          2,
  610.                          0,
  611.                          0,
  612.                          Mychan           );
  613.  
  614.   { To create a new channel attached to port 1 of the UART driver }
  615.  
  616.   Error  := VSerChanNew( 0,
  617.                          UartDriverProc,
  618.                          1,
  619.                          0,
  620.                          0,
  621.                          Mychan           );
  622.  
  623.  
  624. -*)
  625.  
  626. Function  VSerChanNew(              Flags       : WORD;
  627.                                     Proc        : TSerDriverProc;
  628.                                     DriverInfo1 : LONGINT;
  629.                                     DriverInfo2 : LONGINT;
  630.                                     DriverInfo3 : LONGINT;
  631.                                 Var ChanHandle  : TSerHandle    ) : TError;
  632.  
  633. BEGIN
  634.  
  635.   If ( MaxAvail >= SizeOf( TSerChan ) ) Then
  636.   BEGIN
  637.  
  638.     New( ChanHandle );
  639.     FillChar( ChanHandle^, SizeOf( TSerChan ), 0 );
  640.  
  641.     ChanHandle^.Sig  := $CBAD;
  642.  
  643.     VSerChanNew := VSerDriverNew( ChanHandle,
  644.                                   Proc,
  645.                                   DriverInfo1,
  646.                                   DriverInfo2,
  647.                                   DriverInfo3      );
  648.  
  649.   END  { If MaxAvail }
  650.  
  651.   Else
  652.     VSerChanNew := ser_NoMemAvail;
  653.  
  654. END;  { VSerChanNew }
  655.  
  656. {────────────────────────────────────────────────────────────────────────────}
  657.  
  658. (*-
  659.  
  660. [FUNCTION]
  661.  
  662. Procedure VSerGetCaps(              ChanHandle  : TSerHandle;
  663.                                     Caps        : PSerCaps    );
  664.  
  665. [PARAMETERS]
  666.  
  667. Caps        Pointer to TSerCaps serial capabilities record.
  668.  
  669. [RETURNS]
  670.  
  671. "Caps" filled in.
  672.  
  673. [DESCRIPTION]
  674.  
  675. This function will obtain the capabilities information from the
  676. specified serial channel.
  677.  
  678.   TSerCaps = RECORD
  679.  
  680.     CanDoEventProcs  : BOOLEAN;   { This serial channel supports EVENTS }
  681.     CanChangeInBuff  : BOOLEAN;   { INPUT buffer size can be changed    }
  682.     CanChangeOutBuff : BOOLEAN;   { OUTPUT buffer size can be changed   }
  683.     CanControlRTS    : BOOLEAN;   { RTS can be manually raised/lowered  }
  684.  
  685.   END;
  686.  
  687. [SEE-ALSO]
  688.  
  689. [EXAMPLE]
  690.  
  691. Var
  692.  
  693.   SCaps : TSerCaps;
  694.  
  695. BEGIN
  696.  
  697.   VSerGetCaps( MyChan, @SCaps );
  698.  
  699.   If SCaps.CanDoEventProc=TRUE Then
  700.     WriteLn('This serial channel supports events.')
  701.   Else
  702.     WriteLn('This serial channel does NOT support events.');
  703.  
  704.  
  705. END;
  706.  
  707. -*)
  708.  
  709. Procedure VSerGetCaps(              ChanHandle  : TSerHandle;
  710.                                     Caps        : PSerCaps    );
  711.  
  712. BEGIN
  713.  
  714. END;  { VSerGetCaps }
  715.  
  716.  
  717. {────────────────────────────────────────────────────────────────────────────}
  718.  
  719. (*-
  720.  
  721. [FUNCTION]
  722.  
  723. Procedure VSerChanDispose(          ChanHandle  : TSerHandle    ) ;
  724.  
  725. [PARAMETERS]
  726.  
  727. ChanHandle  serial channel handle
  728.  
  729. [RETURNS]
  730.  
  731. (None)
  732.  
  733. [DESCRIPTION]
  734.  
  735. This function disposes of a serial channel that was previously allocated
  736. via a call to VSerChanNew.  This function automatically calls
  737. VSerDriverDispose to insure that the serial driver connected to this
  738. channel is properly closed.  This function should _always_ be called
  739. when you are done with the serial channel.  This function automatically
  740. calls VSerChanDeactivate.
  741.  
  742. [SEE-ALSO]
  743.  
  744. [EXAMPLE]
  745.  
  746.  
  747.   VSerchanDispose( MyChan );
  748.  
  749. -*)
  750.  
  751. Procedure VSerChanDispose(          ChanHandle  : TSerHandle    ) ;
  752.  
  753. BEGIN
  754.  
  755.   If ChanHandle^.Sig = $CBAD Then
  756.   BEGIN
  757.  
  758.     If @ChanHandle^.SerDriverProc<>NIL Then
  759.       VSerDriverDispose( ChanHandle );
  760.  
  761.     Dispose( ChanHandle );
  762.  
  763.   END;
  764.  
  765. END;  { VSerChanDispose }
  766.  
  767.  
  768.  
  769. {────────────────────────────────────────────────────────────────────────────}
  770.  
  771. (*-
  772.  
  773. [FUNCTION]
  774.  
  775. Function  VSerDriverNew(            Chan        : TSerHandle;
  776.                                     Proc        : TSerDriverProc;
  777.                                     DriverInfo1 : LONGINT;
  778.                                     DriverInfo2 : LONGINT;
  779.                                     DriverInfo3 : LONGINT      ) : TError;
  780.  
  781. [PARAMETERS]
  782.  
  783. Chan        Serial channel handle
  784. Proc        Pointer to Serial Device Driver Procedure
  785. DriverInfo1 paramater passed to the serial driver procedure.
  786. DriverInfo1 paramater passed to the serial driver procedure.
  787. DriverInfo1 paramater passed to the serial driver procedure.
  788.  
  789. [RETURNS]
  790.  
  791. 0 if successfull, otherwisea serial error value.
  792.  
  793. [DESCRIPTION]
  794.  
  795. This function attaches a new serial driver to the specified serial
  796. channel.  It should only be used when you want to dynamically change
  797. what serial driver or port a channel is attached to after the
  798. channel has been created.
  799.  
  800. [SEE-ALSO]
  801.  
  802. [EXAMPLE]
  803.  
  804.   { attach UART serial driver on COM1 to the channel }
  805.  
  806.   Err := VSerDriverNew( MyChan,
  807.                         UartDriverProc,
  808.                         1,
  809.                         0,
  810.                         0                     );
  811.  
  812. -*)
  813.  
  814. Function  VSerDriverNew(            Chan        : TSerHandle;
  815.                                     Proc        : TSerDriverProc;
  816.                                     DriverInfo1 : LONGINT;
  817.                                     DriverInfo2 : LONGINT;
  818.                                     DriverInfo3 : LONGINT      ) : TError;
  819.  
  820. BEGIN
  821.  
  822.   With Chan^ Do
  823.   BEGIN
  824.  
  825.     SDP.Func          := SDFDriverNew;
  826.     SDP.DriverInfo1   := DriverInfo1;
  827.     SDP.DriverInfo2   := DriverInfo2;
  828.     SDP.DriverInfo3   := DriverInfo3;
  829.     SDP.SerDriverProc := Proc;
  830.     SDP.Error         := 0;
  831.  
  832.     Proc( @SDP );
  833.  
  834.     If SDP.Error=0 Then          { install }
  835.     BEGIN
  836.  
  837.       Chan^.SerDriverProc := SDP.SerDriverProc;
  838.       Chan^.SerDriverID   := SDP.IData;
  839.  
  840.       Chan^.WriteFlags    := 0;
  841.       Chan^.WriteTimeout  := -1;
  842.       Chan^.ReadFlags     := 0;
  843.       Chan^.ReadTimeout   := -1;
  844.  
  845.       Chan^.ErrorCh       := #255;
  846.  
  847.       VSerDriverNew := 0;
  848.  
  849.     END  { Uf SDP.Error }
  850.     Else
  851.     BEGIN
  852.  
  853.       VSerDriverNew := SDP.Error;
  854.  
  855.     END; { If SDP.Error / Else }  { (install) / else }
  856.  
  857.   END;  { With Chan^ }
  858.  
  859. END;  { VSerDriverNew }
  860.  
  861. {────────────────────────────────────────────────────────────────────────────}
  862.  
  863. (*-
  864.  
  865. [FUNCTION]
  866.  
  867. Procedure VSerDriverDispose(        Handle      : TSerHandle    ) ;
  868.  
  869. [PARAMETERS]
  870.  
  871. Handle      serial channel handle
  872.  
  873. [RETURNS]
  874.  
  875. nothing.
  876.  
  877. [DESCRIPTION]
  878.  
  879. This function properly closes the serial driver attached to the
  880. specified serial channel.
  881.  
  882. [SEE-ALSO]
  883.  
  884. [EXAMPLE]
  885.  
  886. -*)
  887.  
  888. Procedure VSerDriverDispose(        Handle      : TSerHandle    ) ;
  889.  
  890. BEGIN
  891.  
  892.   VSerChanDeactivate( Handle );
  893.  
  894.   With Handle^ Do
  895.   BEGIN
  896.  
  897.     SDP.Func          := SDFDriverDispose;
  898.     SDP.Error         := 0;
  899.  
  900.     SerDriverProc( @SDP );
  901.  
  902.     @SDP.SerDriverProc := NIL;  { !! }
  903.  
  904.   END;  { With Handle^ }
  905.  
  906. END;  { VSerDriverDispose }
  907.  
  908. {────────────────────────────────────────────────────────────────────────────}
  909.  
  910. {-----------------------------------}
  911. { Serial Channel control procedures }
  912. {-----------------------------------}
  913.  
  914. (*-
  915.  
  916. [FUNCTION]
  917.  
  918. Function  VSerChanActivate(         Chan        : TSerHandle;
  919.                                     CommParam   : PCommParam    ) : TError;
  920.  
  921. [PARAMETERS]
  922.  
  923. Chan        Serial channel handle
  924. CommParam   Pointer to a serial communications paramaters record
  925.  
  926. [RETURNS]
  927.  
  928. 0 if successfull, otherwise a serial error value.
  929.  
  930. [DESCRIPTION]
  931.  
  932. This function activates the specified serial channel.  This function
  933. must be called after the channel has been created (VSerChannew),
  934. but before any other functions are used.
  935.  
  936. CommParam is a pointer to a serial communications paramaters structure
  937. that should contain the initial settings of the serial channel:
  938.  
  939.   TCommParam = RECORD
  940.  
  941.     BaudRate  : LONGINT;         { Baudrate for the channel }
  942.     Parity    : CHAR;            { Parity (N,E,O,M, or S    }
  943.     DataBits  : BYTE;            { # of data bits (8/7)     }
  944.     StopBits  : BYTE;            { # of stop bits (0/1/2)   }
  945.  
  946.   END;
  947.  
  948. [SEE-ALSO]
  949.  
  950. [EXAMPLE]
  951.  
  952.  
  953.   { To create a new channel attached to port 2 of the FOSSSIL driver }
  954.  
  955.   Error  := VSerChanNew( 0,
  956.                          FosDriverProc,
  957.                          2,
  958.                          0,
  959.                          0,
  960.                          Mychan           );
  961.  
  962.   { to activate the channel at settings 2400bps, no parity, 8 data bits }
  963.   { and 1 stop bit.                                                     }
  964.  
  965.   CP.BaudRate   := 2400;
  966.   CP.Parity     := 'N';
  967.   CP.DataBits   := 8;
  968.   CP.StopBits   := 1;
  969.  
  970.   Err := VSerChanActivate( Mychan, @CP );
  971.  
  972.  
  973. -*)
  974.  
  975. Function  VSerChanActivate(         Chan        : TSerHandle;
  976.                                     CommParam   : PCommParam    ) : TError;
  977.  
  978. BEGIN
  979.  
  980.   If Chan^.Sig = $CBAD Then
  981.  
  982.     With Chan^ Do
  983.     BEGIN
  984.  
  985.       SDP.Func      := SDFActivate;
  986.       SDP.CommParam := CommParam;
  987.       SDP.Error     := 0;
  988.  
  989.       SerDriverProc( @SDP );
  990.  
  991.       VSerChanActivate := SDP.Error;
  992.  
  993.     END  { With Chan^ }
  994.  
  995.   Else
  996.     VSerChanActivate := $FBAD;
  997.  
  998. END;  { VSerChanActivate }
  999.  
  1000. {────────────────────────────────────────────────────────────────────────────}
  1001.  
  1002. (*-
  1003.  
  1004. [FUNCTION]
  1005.  
  1006. Function  VSerChanDeactivate(       Chan        : TSerHandle     ) : TError;
  1007.  
  1008. [PARAMETERS]
  1009.  
  1010. Chan        Serial channel handle
  1011.  
  1012. [RETURNS]
  1013.  
  1014. 0 if successfull, otherwise a serial error value.
  1015.  
  1016. [DESCRIPTION]
  1017.  
  1018. This function deactivates the port to which the specified serial
  1019. channel is attached.
  1020.  
  1021. [SEE-ALSO]
  1022.  
  1023. [EXAMPLE]
  1024.  
  1025.   VSerChanDeactivate( Chan );
  1026.  
  1027. -*)
  1028.  
  1029. Function  VSerChanDeactivate(       Chan        : TSerHandle    ) : TError;
  1030.  
  1031. BEGIN
  1032.  
  1033.   If Chan^.Sig = $CBAD Then
  1034.  
  1035.     With Chan^ Do
  1036.     BEGIN
  1037.  
  1038.       SDP.Func      := SDFDeActivate;
  1039.       SDP.Error     := 0;
  1040.  
  1041.       SerDriverProc( @SDP );
  1042.  
  1043.       VSerChanDeactivate := SDP.Error;
  1044.  
  1045.     END  { With Chan^ }
  1046.  
  1047.   Else
  1048.     VSerChanDeactivate := $FBAD;
  1049.  
  1050. END;  { VSerChanDeactivate }
  1051.  
  1052. {───────────────────────────────────────────────────────────────────────────}
  1053. {                                                                           }
  1054. {             C O M M     P A R A M        F U N C T I O N S                }
  1055. {                                                                           }
  1056. {───────────────────────────────────────────────────────────────────────────}
  1057.  
  1058. (*-
  1059.  
  1060. [FUNCTION]
  1061.  
  1062. Function  VSerGetCommParam(         Chan        : TSerHandle;
  1063.                                     CommParam   : PCommParam    ) : TError;
  1064.  
  1065. [PARAMETERS]
  1066.  
  1067. Chan        Serial channel handle
  1068. CommParam   pointer to a variable of type TCommParam that will receive
  1069.             the current communications paramaters.
  1070.  
  1071. [RETURNS]
  1072.  
  1073. CommParam   filled in with the current communications paramaters of
  1074.             the specified serial channel.
  1075.  
  1076. [DESCRIPTION]
  1077.  
  1078. This function gets the current communications paramaters of the
  1079. specified serial channel.
  1080.  
  1081.   TCommParam = RECORD
  1082.  
  1083.     BaudRate  : LONGINT;         { Baudrate for the channel }
  1084.     Parity    : CHAR;            { Parity (N,E,O,M, or S    }
  1085.     DataBits  : BYTE;            { # of data bits (8/7)     }
  1086.     StopBits  : BYTE;            { # of stop bits (0/1/2)   }
  1087.  
  1088.   END;
  1089.  
  1090. [SEE-ALSO]
  1091.  
  1092. [EXAMPLE]
  1093.  
  1094. Var
  1095.  
  1096.   CP  : TCommParam;
  1097.   Err : TError;
  1098.  
  1099. BEGIN
  1100.  
  1101.   Err := VSerGetCommParam( MyChan, @CP );
  1102.  
  1103.   WriteLn( 'Baud Rate .......... ', CP.Baudrate );
  1104.   WriteLn( 'Parity ............. ', CP.Parity   );
  1105.   WriteLn( 'Data Bits .......... ', CP.DataBits );
  1106.   WriteLn( 'Stop Bits .......... ', CP.StopBits );
  1107.  
  1108.  
  1109. END;
  1110.  
  1111.  
  1112. -*)
  1113.  
  1114. Function  VSerGetCommParam(         Chan        : TSerHandle;
  1115.                                     CommParam   : PCommParam    ) : TError;
  1116.  
  1117. BEGIN
  1118.  
  1119.   If Chan^.Sig = $CBAD Then
  1120.  
  1121.     With Chan^ Do
  1122.     BEGIN
  1123.  
  1124.       SDP.Func      := SDFGetCommParam;
  1125.       SDP.Error     := 0;
  1126.  
  1127.       SerDriverProc( @SDP );
  1128.  
  1129.       CommParam        := SDP.CommParam;
  1130.  
  1131.       VSerGetCommParam := SDP.Error;
  1132.  
  1133.     END  { With Chan^ }
  1134.  
  1135.   Else
  1136.     VSerGetCommParam := $FBAD;
  1137.  
  1138. END;  { VSerGetCommParam }
  1139.  
  1140. {────────────────────────────────────────────────────────────────────────────}
  1141.  
  1142. (*-
  1143.  
  1144. [FUNCTION]
  1145.  
  1146. Function  VSerSetCommParam(         Chan        : TSerHandle;
  1147.                                     CommParam   : PCommParam    ) : TError;
  1148.  
  1149. [PARAMETERS]
  1150.  
  1151. Chan        Serial channel handle
  1152. CommParam   a variable of the TCommParam structure type.
  1153.  
  1154. [RETURNS]
  1155.  
  1156. 0 if successfull, otherwise a serial error value.
  1157.  
  1158. [DESCRIPTION]
  1159.  
  1160. This function sets the communications paramaters of the specified
  1161. serial channel.
  1162.  
  1163.  
  1164.   TCommParam = RECORD
  1165.  
  1166.     BaudRate  : LONGINT;         { Baudrate for the channel }
  1167.     Parity    : CHAR;            { Parity (N,E,O,M, or S    }
  1168.     DataBits  : BYTE;            { # of data bits (8/7)     }
  1169.     StopBits  : BYTE;            { # of stop bits (0/1/2)   }
  1170.  
  1171.   END;
  1172.  
  1173.  
  1174. [SEE-ALSO]
  1175.  
  1176. [EXAMPLE]
  1177.  
  1178. Function SetComm2To2400N81;
  1179.  
  1180. Var
  1181.  
  1182.   CP : TCommParam;
  1183.  
  1184. BEGIN
  1185.  
  1186.   { global variable mychan should have serial channel handle }
  1187.  
  1188.   CP.ComPort    := 2;
  1189.   CP.BaudRate   := 2400;
  1190.   CP.Parity     := 'N';
  1191.   CP.DataBits   := 8;
  1192.   CP.StopBits   := 1;
  1193.  
  1194.   Err := VSerSetCommParam( MyChan, @CP );
  1195.  
  1196. END;
  1197.  
  1198. -*)
  1199.  
  1200. Function  VSerSetCommParam(         Chan        : TSerHandle;
  1201.                                     CommParam   : PCommParam    ) : TError;
  1202.  
  1203. BEGIN
  1204.  
  1205.   If Chan^.Sig = $CBAD Then
  1206.  
  1207.     With Chan^ Do
  1208.     BEGIN
  1209.  
  1210.       SDP.Func      := SDFSetCommParam;
  1211.       SDP.CommParam := CommParam;
  1212.       SDP.Error     := 0;
  1213.  
  1214.       SerDriverProc( @SDP );
  1215.  
  1216.       VSerSetCommParam := SDP.Error;
  1217.  
  1218.     END  { With Chan^ }
  1219.  
  1220.   Else
  1221.     VSerSetCommParam := $FBAD;
  1222.  
  1223. END;  { VSerSetCommParam }
  1224.  
  1225.  
  1226. {────────────────────────────────────────────────────────────────────────────}
  1227.  
  1228. (*-
  1229.  
  1230. [FUNCTION]
  1231.  
  1232. Function  VSerGetBaud(              Chan        : TSerHandle    ) : LONGINT;
  1233.  
  1234. [PARAMETERS]
  1235.  
  1236. Chan        Serial channel handle
  1237.  
  1238. [RETURNS]
  1239.  
  1240. Current baud rate of the specified channel.
  1241. -1 if an error occurred.
  1242.  
  1243. [DESCRIPTION]
  1244.  
  1245. This function gets and returns the current baud rate of the
  1246. specified serial channel.
  1247.  
  1248. [SEE-ALSO]
  1249.  
  1250. [EXAMPLE]
  1251.  
  1252.   WriteLn(' Baud Rate = ', VSerGetbaud( MyChan ) );
  1253.  
  1254. -*)
  1255.  
  1256. Function  VSerGetBaud(              Chan        : TSerHandle    ) : LONGINT;
  1257.  
  1258. Var
  1259.  
  1260.   CP   : TCommParam;
  1261.  
  1262. BEGIN
  1263.  
  1264.   If VSerGetCommParam( Chan, @CP )=0 Then
  1265.   BEGIN
  1266.     VSerGetBaud := CP.BaudRate;
  1267.   END
  1268.   ELSE
  1269.     VSerGetBaud := -1;
  1270.  
  1271. END;
  1272.  
  1273. {────────────────────────────────────────────────────────────────────────────}
  1274.  
  1275. (*-
  1276.  
  1277. [FUNCTION]
  1278.  
  1279. Function  VSerGetParity(            Chan        : TSerHandle    ) : CHAR;
  1280.  
  1281. [PARAMETERS]
  1282.  
  1283. Chan        Serial channel
  1284.  
  1285. [RETURNS]
  1286.  
  1287. Current parity setting the specified channel.
  1288.  
  1289.   ?    Parity unknown/function error.
  1290.   N    No parity
  1291.   E    Even parity
  1292.   O    Odd Parity
  1293.   M    Mark parity
  1294.   S    Space parity
  1295.  
  1296. [DESCRIPTION]
  1297.  
  1298. This function returns the current parity setting of the specified
  1299. serial channel.
  1300.  
  1301. [SEE-ALSO]
  1302.  
  1303. [EXAMPLE]
  1304.  
  1305. -*)
  1306.  
  1307. Function  VSerGetParity(            Chan        : TSerHandle    ) : CHAR;
  1308.  
  1309. Var
  1310.  
  1311.   CP   : TCommParam;
  1312.  
  1313. BEGIN
  1314.  
  1315.   If VSerGetCommParam( Chan, @CP )=0 Then
  1316.   BEGIN
  1317.     VSerGetParity := CP.Parity;
  1318.   END
  1319.   ELSE
  1320.     VSerGetParity := '?';
  1321.  
  1322. END;
  1323.  
  1324. {────────────────────────────────────────────────────────────────────────────}
  1325.  
  1326. (*-
  1327.  
  1328. [FUNCTION]
  1329.  
  1330. Function  VSerGetDataBits(          Chan        : TSerHandle    ) : BYTE;
  1331.  
  1332. [PARAMETERS]
  1333.  
  1334. Chan        Serial channel
  1335.  
  1336. [RETURNS]
  1337.  
  1338. The current data-bits setting of the specified serial channel
  1339. ($FF if an error occurred)
  1340.  
  1341. [DESCRIPTION]
  1342.  
  1343. This function returns the current data-bits setting of the specified
  1344. serial channel.  If the information is unknown or an error occurred,
  1345. this function will return $FF.
  1346.  
  1347. [SEE-ALSO]
  1348.  
  1349. [EXAMPLE]
  1350.  
  1351.   WriteLn('Data Bits = ',VSerGetDataBits( MyChan ) );
  1352.  
  1353. -*)
  1354.  
  1355. Function  VSerGetDataBits(          Chan        : TSerHandle    ) : BYTE;
  1356.  
  1357. Var
  1358.  
  1359.   CP   : TCommParam;
  1360.  
  1361. BEGIN
  1362.  
  1363.   If VSerGetCommParam( Chan, @CP )=0 Then
  1364.   BEGIN
  1365.     VSerGetDatabits := CP.Databits;
  1366.   END
  1367.   ELSE
  1368.     VSerGetDatabits := $FF;
  1369.  
  1370. END;
  1371.  
  1372. {────────────────────────────────────────────────────────────────────────────}
  1373.  
  1374. (*-
  1375.  
  1376. [FUNCTION]
  1377.  
  1378. Function  VSerGetStopBits(          Chan        : TSerHandle    ) : BYTE;
  1379.  
  1380. [PARAMETERS]
  1381.  
  1382. Chan        Serial channel
  1383.  
  1384. [RETURNS]
  1385.  
  1386. Current stop-bits setting of the specifed serial channel.
  1387. ($FF if an error occurred)
  1388.  
  1389. This function returns the current stop-bits setting of the specified
  1390. serial channel.  If the information is unknown or an error occurred,
  1391. this function will return $FF.
  1392.  
  1393. [SEE-ALSO]
  1394.  
  1395. [EXAMPLE]
  1396.  
  1397.   WriteLn('Stop Bits = ',VSerGetStopBits( MyChan ) );
  1398.  
  1399. -*)
  1400.  
  1401. Function  VSerGetStopBits(          Chan        : TSerHandle    ) : BYTE;
  1402.  
  1403. Var
  1404.  
  1405.   CP   : TCommParam;
  1406.  
  1407. BEGIN
  1408.  
  1409.   If VSerGetCommParam( Chan, @CP )=0 Then
  1410.   BEGIN
  1411.     VSerGetStopBits := CP.StopBits;
  1412.   END
  1413.   ELSE
  1414.     VSerGetStopBits := $FF;
  1415.  
  1416. END;
  1417.  
  1418. {────────────────────────────────────────────────────────────────────────────}
  1419.  
  1420. (*-
  1421.  
  1422. [FUNCTION]
  1423.  
  1424. Function  VSerSetBaud(              Chan        : TSerHandle;
  1425.                                     BaudRate    : LONGINT       ) : TError;
  1426.  
  1427. [PARAMETERS]
  1428.  
  1429. Chan        Serial channel
  1430. Baudrate    new baudrate
  1431.  
  1432. [RETURNS]
  1433.  
  1434. 0 if successfull, otherwise a serial error.
  1435.  
  1436. [DESCRIPTION]
  1437.  
  1438. This function changes the baud rate of the specifed serial channel
  1439. to the new value "baudrate"
  1440.  
  1441. [SEE-ALSO]
  1442.  
  1443. [EXAMPLE]
  1444.  
  1445.   Err := VSerSetBaud( MyChan,
  1446.                       19200     );
  1447.  
  1448.  
  1449. -*)
  1450.  
  1451. Function  VSerSetBaud(              Chan        : TSerHandle;
  1452.                                     BaudRate    : LONGINT       ) : TError;
  1453.  
  1454. Var
  1455.  
  1456.   CP   : TCommParam;
  1457.  
  1458. BEGIN
  1459.  
  1460.   If VSerGetCommParam( Chan, @CP )=0 Then
  1461.   BEGIN
  1462.     CP.BaudRate := BaudRate;
  1463.  
  1464.     VSerSetBaud := VSerSetCommParam( Chan, @CP );
  1465.   END
  1466.   ELSE
  1467.     VSerSetBaud := $FFFF;
  1468.  
  1469. END;
  1470.  
  1471. {────────────────────────────────────────────────────────────────────────────}
  1472.  
  1473. (*-
  1474.  
  1475. [FUNCTION]
  1476.  
  1477. Function  VSerSetParity(            Chan        : TSerHandle;
  1478.                                     Parity      : CHAR          ) : TError;
  1479.  
  1480. [PARAMETERS]
  1481.  
  1482. Chan        Serial channel handle
  1483. Parity      new parity value
  1484.  
  1485. [RETURNS]
  1486.  
  1487. 0 if successfull, otherwise a serial error value.
  1488.  
  1489. [DESCRIPTION]
  1490.  
  1491. This function changes the parity setting of the specified serial
  1492. channel.  The parity value can be any one of the following:
  1493.  
  1494.   N    No parity
  1495.   E    Even parity
  1496.   O    Odd Parity
  1497.   M    Mark parity
  1498.   S    Space parity
  1499.  
  1500. [SEE-ALSO]
  1501.  
  1502. [EXAMPLE]
  1503.  
  1504.   Err := VSerSetParity( MyChan, 'N' );
  1505.  
  1506. -*)
  1507.  
  1508. Function  VSerSetParity(            Chan        : TSerHandle;
  1509.                                     Parity      : CHAR          ) : TError;
  1510.  
  1511.  
  1512. Var
  1513.  
  1514.   CP   : TCommParam;
  1515.  
  1516. BEGIN
  1517.  
  1518.   If VSerGetCommParam( Chan, @CP )=0 Then
  1519.   BEGIN
  1520.     CP.Parity := Parity;
  1521.  
  1522.     VSerSetParity := VSerSetCommParam( Chan, @CP );
  1523.   END
  1524.   ELSE
  1525.     VSerSetParity := $FFFF;
  1526.  
  1527. END;
  1528.  
  1529. {────────────────────────────────────────────────────────────────────────────}
  1530.  
  1531. (*-
  1532.  
  1533. [FUNCTION]
  1534.  
  1535. Function  VSerSetDataBits(          Chan        : TSerHandle;
  1536.                                     DataBits    : WORD          ) : TError;
  1537.  
  1538. [PARAMETERS]
  1539.  
  1540. Chan        Serial channel handle
  1541. Databits    new data-bits setting
  1542.  
  1543. [RETURNS]
  1544.  
  1545. 0 if successfull, otherwise a serial error value.
  1546.  
  1547. [DESCRIPTION]
  1548.  
  1549. This function changes the data-bits setting of the specified serial
  1550. channel.  The value is typically other 7 or 8.
  1551.  
  1552. [SEE-ALSO]
  1553.  
  1554. [EXAMPLE]
  1555.  
  1556.   Err := VSerSetDataBits( MyChan, 8 );
  1557.  
  1558. -*)
  1559.  
  1560. Function  VSerSetDataBits(          Chan        : TSerHandle;
  1561.                                     DataBits    : WORD          ) : TError;
  1562.  
  1563. Var
  1564.  
  1565.   CP   : TCommParam;
  1566.  
  1567. BEGIN
  1568.  
  1569.   If VSerGetCommParam( Chan, @CP )=0 Then
  1570.   BEGIN
  1571.     CP.Databits := Databits;
  1572.  
  1573.     VSerSetDatabits := VSerSetCommParam( Chan, @CP );
  1574.   END
  1575.   ELSE
  1576.     VSerSetDatabits := $FFFF;
  1577.  
  1578. END;
  1579.  
  1580. {────────────────────────────────────────────────────────────────────────────}
  1581.  
  1582. (*-
  1583.  
  1584. [FUNCTION]
  1585.  
  1586. Function  VSerSetStopBits(          Chan        : TSerHandle;
  1587.                                     StopBits    : WORD          ) : TError;
  1588.  
  1589. [PARAMETERS]
  1590.  
  1591. Chan        Serial channel handle
  1592. Stopbits    new stop-bits setting
  1593.  
  1594. [RETURNS]
  1595.  
  1596. 0 if successfull, otherwise a serial error value.
  1597.  
  1598. [DESCRIPTION]
  1599.  
  1600. This function changes the stop-bits setting of the specified serial
  1601. channel.  The value is typically other 0, 1 or 2.
  1602.  
  1603. [SEE-ALSO]
  1604.  
  1605. [EXAMPLE]
  1606.  
  1607.   Err := VSerSetStopBits( MyChan, 1 );
  1608.  
  1609. -*)
  1610.  
  1611. Function  VSerSetStopBits(          Chan        : TSerHandle;
  1612.                                     StopBits    : WORD          ) : TError;
  1613.  
  1614. Var
  1615.  
  1616.   CP   : TCommParam;
  1617.  
  1618. BEGIN
  1619.  
  1620.   If VSerGetCommParam( Chan, @CP )=0 Then
  1621.   BEGIN
  1622.     CP.Stopbits := StopBits;
  1623.  
  1624.     VSerSetStopbits := VSerSetCommParam( Chan, @CP );
  1625.   END
  1626.   ELSE
  1627.     VSerSetStopbits := $FFFF;
  1628.  
  1629. END;
  1630.  
  1631.  
  1632.  
  1633.  
  1634. {───────────────────────────────────────────────────────────────────────────}
  1635. {                                                                           }
  1636. {             F L O W     C O N T R O L    F U N C T I O N S                }
  1637. {                                                                           }
  1638. {───────────────────────────────────────────────────────────────────────────}
  1639.  
  1640. (*-
  1641.  
  1642. [FUNCTION]
  1643.  
  1644. Function  VSerGetFlowConType(       Chan        : TSerHandle    ) : INTEGER;
  1645.  
  1646. [PARAMETERS]
  1647.  
  1648. Chan        Serial channel handle
  1649.  
  1650. [RETURNS]
  1651.  
  1652. [DESCRIPTION]
  1653.  
  1654. [SEE-ALSO]
  1655.  
  1656. [EXAMPLE]
  1657.  
  1658. -*)
  1659.  
  1660. Function  VSerGetFlowConType(       Chan        : TSerHandle    ) : INTEGER;
  1661.  
  1662. BEGIN
  1663.  
  1664.   If Chan^.Sig = $CBAD Then
  1665.  
  1666.     With Chan^ Do
  1667.     BEGIN
  1668.  
  1669.       SDP.Func      := SDFGetFlowConType;
  1670.       SDP.Error     := 0;
  1671.  
  1672.       SerDriverProc( @SDP );
  1673.  
  1674.       VSerGetFlowConType := SDP.FlowConType;
  1675.  
  1676.     END  { With Chan^ }
  1677.  
  1678.   Else
  1679.     VSerGetFlowConType := -1;
  1680.  
  1681. END;  { VSerGetFlowConType }
  1682.  
  1683. {────────────────────────────────────────────────────────────────────────────}
  1684.  
  1685. (*-
  1686.  
  1687. [FUNCTION]
  1688.  
  1689. Function  VSerSetFlowConType(       Chan        : TSerHandle;
  1690.                                     FlowConType : INTEGER       ) : TError;
  1691.  
  1692. [PARAMETERS]
  1693.  
  1694. Chan        Serial channel handle
  1695. FlowconType ?
  1696.  
  1697. [RETURNS]
  1698.  
  1699. [DESCRIPTION]
  1700.  
  1701. [SEE-ALSO]
  1702.  
  1703. [EXAMPLE]
  1704.  
  1705. -*)
  1706.  
  1707. Function  VSerSetFlowConType(       Chan        : TSerHandle;
  1708.                                     FlowConType : INTEGER       ) : TError;
  1709.  
  1710. BEGIN
  1711.  
  1712.   If Chan^.Sig = $CBAD Then
  1713.  
  1714.     With Chan^ Do
  1715.     BEGIN
  1716.  
  1717.       SDP.Func        := SDFSetFlowConType;
  1718.       SDP.FlowConType := FlowConType;
  1719.       SDP.Error       := 0;
  1720.  
  1721.       SerDriverProc( @SDP );
  1722.  
  1723.       VSerSetFlowConType := SDP.Error;
  1724.  
  1725.     END  { With Chan^ }
  1726.  
  1727.   Else
  1728.     VSerSetFlowConType := $FBAD;
  1729.  
  1730. END;  { VSerSetFlowConType }
  1731.  
  1732. {────────────────────────────────────────────────────────────────────────────}
  1733.  
  1734.  
  1735. (*-
  1736.  
  1737. [FUNCTION]
  1738.  
  1739. Function  VSerGetFlowConChars(      Chan        : TSerHandle;
  1740.                                 Var Startchar   : CHAR;
  1741.                                 Var Stopchar    : CHAR          ) : TError;
  1742.  
  1743. [PARAMETERS]
  1744.  
  1745. Chan        Serial channel handle
  1746. FlowconType ?
  1747.  
  1748. [RETURNS]
  1749.  
  1750. [DESCRIPTION]
  1751.  
  1752. [SEE-ALSO]
  1753.  
  1754. [EXAMPLE]
  1755.  
  1756. -*)
  1757.  
  1758.  
  1759. Function  VSerGetFlowConChars(      Chan        : TSerHandle;
  1760.                                 Var Startchar   : CHAR;
  1761.                                 Var Stopchar    : CHAR          ) : TError;
  1762.  
  1763.  
  1764. BEGIN
  1765.  
  1766.   If Chan^.Sig = $CBAD Then
  1767.  
  1768.     With Chan^ Do
  1769.     BEGIN
  1770.  
  1771.       SDP.Func      := SDFGetFlowConChars;
  1772.       SDP.Error     := 0;
  1773.  
  1774.       SerDriverProc( @SDP );
  1775.  
  1776.       {!^!}
  1777.  
  1778.     END  { With Chan^ }
  1779.  
  1780.   Else
  1781.     VSerGetFlowConChars := $FFFF;
  1782.  
  1783. END;
  1784.  
  1785. {────────────────────────────────────────────────────────────────────────────}
  1786.  
  1787. (*-
  1788.  
  1789. [FUNCTION]
  1790.  
  1791. Function  VSerSetFlowConChars(      Chan        : TSerHandle;
  1792.                                     Startchar   : CHAR;
  1793.                                     Stopchar    : CHAR          ) : TError;
  1794.  
  1795. [PARAMETERS]
  1796.  
  1797. Chan        Serial channel handle
  1798.  
  1799. [RETURNS]
  1800.  
  1801. [DESCRIPTION]
  1802.  
  1803. [SEE-ALSO]
  1804.  
  1805. [EXAMPLE]
  1806.  
  1807. -*)
  1808.  
  1809.  
  1810. Function  VSerSetFlowConChars(      Chan        : TSerHandle;
  1811.                                     Startchar   : CHAR;
  1812.                                     Stopchar    : CHAR          ) : TError;
  1813.  
  1814. BEGIN
  1815.  
  1816.   If Chan^.Sig = $CBAD Then
  1817.  
  1818.     With Chan^ Do
  1819.     BEGIN
  1820.  
  1821.       SDP.Func      := SDFSetFlowConChars;
  1822.       SDP.Error     := 0;
  1823.  
  1824.       SerDriverProc( @SDP );
  1825.  
  1826.       {!^!}
  1827.  
  1828.     END  { With Chan^ }
  1829.  
  1830.   Else
  1831.     VSerSetFlowConChars := $FFFF;
  1832.  
  1833. END;
  1834.  
  1835. {────────────────────────────────────────────────────────────────────────────}
  1836.  
  1837. (*-
  1838.  
  1839. [FUNCTION]
  1840.  
  1841. Function  VSerTurnSendOn(           Chan        : TSerHandle    ) : TError;
  1842.  
  1843. [PARAMETERS]
  1844.  
  1845. Chan        Serial channel handle
  1846.  
  1847. [RETURNS]
  1848.  
  1849. 0 if successfull, otherwise a serial error value.
  1850.  
  1851. [DESCRIPTION]
  1852.  
  1853. This function ...
  1854.  
  1855. [SEE-ALSO]
  1856.  
  1857. [EXAMPLE]
  1858.  
  1859. -*)
  1860.  
  1861. Function  VSerTurnSendOn(           Chan        : TSerHandle    ) : TError;
  1862.  
  1863. BEGIN
  1864.  
  1865.   If Chan^.Sig = $CBAD Then
  1866.  
  1867.     With Chan^ Do
  1868.     BEGIN
  1869.  
  1870.       SDP.Func      := SDFTurnSendOnOff;
  1871.       SDP.OnOff     := TRUE;
  1872.       SDP.Error     := 0;
  1873.  
  1874.       SerDriverProc( @SDP );
  1875.  
  1876.       VSerTurnSendOn := SDP.Error;
  1877.  
  1878.     END  { With Chan^ }
  1879.  
  1880.   Else
  1881.     VSerTurnSendOn := $FBAD;
  1882.  
  1883. END;  { VSerTurnSendOn }
  1884.  
  1885. {────────────────────────────────────────────────────────────────────────────}
  1886.  
  1887. (*-
  1888.  
  1889. [FUNCTION]
  1890.  
  1891. Function  VSerTurnSendOff(          Chan        : TSerHandle    ) : TError;
  1892.  
  1893. [PARAMETERS]
  1894.  
  1895. Chan        Serial channel handle
  1896.  
  1897. [RETURNS]
  1898.  
  1899. 0 if successfull, otherwise a serial error value.
  1900.  
  1901. [DESCRIPTION]
  1902.  
  1903. This function disables...
  1904.  
  1905. [SEE-ALSO]
  1906.  
  1907. [EXAMPLE]
  1908.  
  1909. -*)
  1910.  
  1911. Function  VSerTurnSendOff(          Chan        : TSerHandle    ) : TError;
  1912.  
  1913. BEGIN
  1914.  
  1915.   If Chan^.Sig = $CBAD Then
  1916.  
  1917.     With Chan^ Do
  1918.     BEGIN
  1919.  
  1920.       SDP.Func      := SDFTurnSendOnOff;
  1921.       SDP.OnOff     := FALSE;
  1922.       SDP.Error     := 0;
  1923.  
  1924.       SerDriverProc( @SDP );
  1925.  
  1926.       VSerTurnSendOff := SDP.Error;
  1927.  
  1928.     END  { With Chan^ }
  1929.  
  1930.   Else
  1931.     VSerTurnSendOff := $FBAD;
  1932.  
  1933. END;  { VSerTurnSendOff }
  1934.  
  1935. {────────────────────────────────────────────────────────────────────────────}
  1936.  
  1937. (*-
  1938.  
  1939. [FUNCTION]
  1940.  
  1941. Function  VserTurnReceiveOn(        Chan        : TSerHandle    ) : TError;
  1942.  
  1943. [PARAMETERS]
  1944.  
  1945. Chan        Serial channel handle
  1946.  
  1947. [RETURNS]
  1948.  
  1949. 0 if successfull, otherwise a serial error value.
  1950.  
  1951. [DESCRIPTION]
  1952.  
  1953. [SEE-ALSO]
  1954.  
  1955. [EXAMPLE]
  1956.  
  1957. -*)
  1958.  
  1959. Function  VserTurnReceiveOn(        Chan        : TSerHandle    ) : TError;
  1960.  
  1961. BEGIN
  1962.  
  1963.   If Chan^.Sig = $CBAD Then
  1964.  
  1965.     With Chan^ Do
  1966.     BEGIN
  1967.  
  1968.       SDP.Func      := SDFTurnReceiveOnOff;
  1969.       SDP.OnOff     := TRUE;
  1970.       SDP.Error     := 0;
  1971.  
  1972.       SerDriverProc( @SDP );
  1973.  
  1974.       VSerTurnReceiveOn := SDP.Error;
  1975.  
  1976.     END  { With Chan^ }
  1977.  
  1978.   Else
  1979.     VSerTurnReceiveOn := $FBAD;
  1980.  
  1981. END;  { VSerTurnReceiveOn }
  1982.  
  1983. {────────────────────────────────────────────────────────────────────────────}
  1984.  
  1985. (*-
  1986.  
  1987. [FUNCTION]
  1988.  
  1989. Function  VSerTurnReceiveOff(       Chan        : TSerHandle    ) : TError;
  1990.  
  1991. [PARAMETERS]
  1992.  
  1993. Chan        Serial channel handle
  1994.  
  1995. [RETURNS]
  1996.  
  1997. [DESCRIPTION]
  1998.  
  1999. 0 if successfull, otherwise a serial error value.
  2000.  
  2001. [SEE-ALSO]
  2002.  
  2003. [EXAMPLE]
  2004.  
  2005. -*)
  2006.  
  2007. Function  VSerTurnReceiveOff(       Chan        : TSerHandle    ) : TError;
  2008.  
  2009. BEGIN
  2010.  
  2011.   If Chan^.Sig = $CBAD Then
  2012.  
  2013.     With Chan^ Do
  2014.     BEGIN
  2015.  
  2016.       SDP.Func      := SDFTurnReceiveOnOff;
  2017.       SDP.OnOff     := FALSE;
  2018.       SDP.Error     := 0;
  2019.  
  2020.       SerDriverProc( @SDP );
  2021.  
  2022.       VSerTurnReceiveOff := SDP.Error;
  2023.  
  2024.     END  { With Chan^ }
  2025.  
  2026.   Else
  2027.     VSerTurnReceiveOff := $FBAD;
  2028.  
  2029. END;  { VSerTurnReceiveOff }
  2030.  
  2031. {───────────────────────────────────────────────────────────────────────────}
  2032. {                                                                           }
  2033. {         L I N E  /  M O D E M    S T A T U S     F U N C T I O N S        }
  2034. {                                                                           }
  2035. {───────────────────────────────────────────────────────────────────────────}
  2036.  
  2037.  
  2038. (*-
  2039.  
  2040. [FUNCTION]
  2041.  
  2042.  
  2043. Function  VSerGetLineControl(       Chan        : TSerHandle    ) : WORD;
  2044.  
  2045. [PARAMETERS]
  2046.  
  2047. Chan        Serial channel handle
  2048.  
  2049. [RETURNS]
  2050.  
  2051. The current line-control value for the specified serial channel.
  2052.  
  2053.  
  2054.        7   6   5   4   3   2   1   0
  2055.            |   |   |   |   |   [-+-]
  2056.            |   |   |   |   |     |
  2057.            |   |   |   |   |     Data Bits (0=5,1=6,2=7,3=8)
  2058.            |   |   |   |   |
  2059.            |   |   |   |   |
  2060.            |   |   |   |   Stop Bits (0=1, 1=2)
  2061.            |   |   |   |
  2062.            |   |   |   |
  2063.            |   |   |   Parity is enabled flag (0=off, 1=on)
  2064.            |   |   |
  2065.            |   |   |
  2066.            |   |   Parity even/odd flag (0=odd, 1=even)
  2067.            |   |
  2068.            |   |
  2069.            |   Sticky parity flag (0=nonsticky,1=sticky)
  2070.            |
  2071.            |
  2072.            Break flag (0=break is off, 1=break is on)
  2073.  
  2074.  
  2075.   cDataBitsMask      = $01+$02;     { Data bits (wordsize) mask    }
  2076.   cDataBits5         = $00;         { Data bits = 5                }
  2077.   cDataBits6         = $01;         { Data bits = 6                }
  2078.   cDataBits7         = $02;         { Data bits = 7                }
  2079.   cDataBits8         = $01+$02;     { Data bits = 8                }
  2080.  
  2081.   cStopBits1         = $00;         { Stop bits = 1                }
  2082.   cStopBits2         = $04;         { Stop bits = 2                }
  2083.  
  2084.   cParityEnable      = $08;         { Enable parity                }
  2085.  
  2086.   cParityEven        = $10;         { even parity                  }
  2087.  
  2088.   cStickyParity      = $20;         { sticky parity                }
  2089.  
  2090.   cBreakOn           = $40;         { turn break on                }
  2091.  
  2092.   cAccessDivLatch    = $80;         { access divisor latch         }
  2093.  
  2094.  
  2095. [DESCRIPTION]
  2096.  
  2097. This function gets and returns the line control value for the
  2098. specified serial channel.
  2099.  
  2100. [SEE-ALSO]
  2101.  
  2102. [EXAMPLE]
  2103.  
  2104. -*)
  2105.  
  2106. Function  VSerGetLineControl(       Chan        : TSerHandle    ) : WORD;
  2107.  
  2108. BEGIN
  2109.  
  2110.   If Chan^.Sig = $CBAD Then
  2111.  
  2112.     With Chan^ Do
  2113.     BEGIN
  2114.  
  2115.       SDP.Func      := SDFGetLineControl;
  2116.       SDP.Error     := 0;
  2117.  
  2118.       SerDriverProc( @SDP );
  2119.  
  2120.       If SDP.Error=0 Then
  2121.         VSerGetLineControl := SDP.Val
  2122.       Else
  2123.         VSerGetLineControl := $FFFF;
  2124.  
  2125.     END  { With Chan^ }
  2126.  
  2127.   Else
  2128.     VSerGetLineControl := $FFFF;
  2129.  
  2130. END;  { VSerGetLineControl }
  2131.  
  2132. {───────────────────────────────────────────────────────────────────────────}
  2133.  
  2134.  
  2135.  
  2136. (*-
  2137.  
  2138. [FUNCTION]
  2139.  
  2140.  
  2141. Function  VSerGetLineStatus(        Chan        : TSerHandle    ) : WORD;
  2142.  
  2143. [PARAMETERS]
  2144.  
  2145. Chan        Serial channel handle
  2146.  
  2147. [RETURNS]
  2148.  
  2149. Line status value of the specified serial channel.
  2150.  
  2151.  
  2152. [DESCRIPTION]
  2153.  
  2154.  
  2155.        7   6   5   4   3   2   1   0--Data is in receive buffer flag
  2156.            |   |   |   |   |   |
  2157.            |   |   |   |   |   |
  2158.            |   |   |   |   |   Read buffer over-run error flag
  2159.            |   |   |   |   |
  2160.            |   |   |   |   |
  2161.            |   |   |   |   Parity error flag
  2162.            |   |   |   |
  2163.            |   |   |   |
  2164.            |   |   |   Framing error flag
  2165.            |   |   |
  2166.            |   |   |
  2167.            |   |   Incoming break flag (0=incoming break off,1=on)
  2168.            |   |
  2169.            |   |
  2170.            |   Trasmit holding register empty flag
  2171.            |
  2172.            |
  2173.            Transmit shift register empty flag
  2174.  
  2175.  
  2176.  
  2177.   cDataInRcvBuff     = $01;         { data in receive buffer       }
  2178.   cOverrunError      = $02;         { overrrun error               }
  2179.   cParityError       = $04;         { parity error                 }
  2180.   cFramingError      = $08;         { framing error                }
  2181.   cIncomingBreak     = $10;         { incoming break detected      }
  2182.   cTHREmpty          = $20;         { Transmit holding reg is empty}
  2183.   cTSREmpty          = $40;         { Transmit shift   reg is empty}
  2184.   cFIFORcvError      = $80;         { 16550 Fifo receive error     }
  2185.  
  2186.  
  2187. [SEE-ALSO]
  2188.  
  2189. [EXAMPLE]
  2190.  
  2191. -*)
  2192.  
  2193. Function  VSerGetLineStatus(        Chan        : TSerHandle    ) : WORD;
  2194.  
  2195. BEGIN
  2196.  
  2197.   If Chan^.Sig = $CBAD Then
  2198.  
  2199.     With Chan^ Do
  2200.     BEGIN
  2201.  
  2202.       SDP.Func      := SDFGetLineStatus;
  2203.       SDP.Error     := 0;
  2204.  
  2205.       SerDriverProc( @SDP );
  2206.  
  2207.       VSerGetLineStatus := (SDP.Status AND $FF00) SHR 8;
  2208.  
  2209.     END  { With Chan^ }
  2210.  
  2211.   Else
  2212.     VSerGetLineStatus := $FFFF;
  2213.  
  2214. END;
  2215.  
  2216. {───────────────────────────────────────────────────────────────────────────}
  2217.  
  2218.  
  2219.  
  2220. (*-
  2221.  
  2222. [FUNCTION]
  2223.  
  2224.  
  2225. Function  VSerGetModemControl(       Chan        : TSerHandle    ) : WORD;
  2226.  
  2227. [PARAMETERS]
  2228.  
  2229. Chan        Serial channel handle
  2230.  
  2231. [RETURNS]
  2232.  
  2233. Modem control value of the specified serial channel.
  2234.  
  2235. [DESCRIPTION]
  2236.  
  2237.  
  2238.  
  2239.        7   6   5   4   3   2   1   0--Data Terminal ready (DTR)
  2240.            |   |   |   |   |   |
  2241.            |   |   |   |   |   |
  2242.            |   |   |   |   |   Ready to send (RTS)
  2243.            |   |   |   |   |
  2244.            |   |   |   |   |
  2245.            |   |   |   |   Unused
  2246.            |   |   |   |
  2247.            |   |   |   |
  2248.            |   |   |   Unused
  2249.  
  2250.  
  2251.   cDTR               = $01;         { Data terminal ready          }
  2252.   cRTS               = $02;         { Ready to send                }
  2253.   cOut1              = $04;         { Out 1 - not used in PCs      }
  2254.  
  2255.   cOut2              = $08;         { Out 2 -                      }
  2256.   cMasterEnableInts  = $08;         {   master enables interrupts  }
  2257.  
  2258.   cLoop              = $10;         { Loop enable (for testing)    }
  2259.  
  2260.  
  2261. [SEE-ALSO]
  2262.  
  2263. [EXAMPLE]
  2264.  
  2265. -*)
  2266.  
  2267. Function  VSerGetModemControl(       Chan        : TSerHandle    ) : WORD;
  2268.  
  2269. BEGIN
  2270.  
  2271.   If Chan^.Sig = $CBAD Then
  2272.  
  2273.     With Chan^ Do
  2274.     BEGIN
  2275.  
  2276.       SDP.Func      := SDFGetModemControl;
  2277.       SDP.Status    := 0;
  2278.  
  2279.       SerDriverProc( @SDP );
  2280.  
  2281.       If SDP.Error=0 Then
  2282.         VSerGetModemControl := SDP.Val
  2283.       Else
  2284.         VSerGetModemControl := $FFFF;
  2285.  
  2286.     END  { With Chan^ }
  2287.  
  2288.   Else
  2289.     VSerGetModemControl := $FFFF;
  2290.  
  2291. END;
  2292.  
  2293.  
  2294. {───────────────────────────────────────────────────────────────────────────}
  2295.  
  2296.  
  2297.  
  2298. (*-
  2299.  
  2300. [FUNCTION]
  2301.  
  2302.  
  2303. Function  VSerGetModemStatus(        Chan        : TSerHandle    ) : WORD;
  2304.  
  2305. [PARAMETERS]
  2306.  
  2307. Chan        Serial channel handle
  2308.  
  2309. [RETURNS]
  2310.  
  2311. Modem status value for the specified serial channel.
  2312.  
  2313. [DESCRIPTION]
  2314.  
  2315.        7   6   5   4   3   2   1   0--CTS has changed flag
  2316.        |   |   |   |   |   |   |
  2317.        |   |   |   |   |   |   |
  2318.        |   |   |   |   |   |   DSR has changed flag
  2319.        |   |   |   |   |   |
  2320.        |   |   |   |   |   |
  2321.        |   |   |   |   |   RING has changed flag
  2322.        |   |   |   |   |
  2323.        |   |   |   |   |
  2324.        |   |   |   |   DCD (carrier) has changed flag
  2325.        |   |   |   |
  2326.        |   |   |   |
  2327.        |   |   |   CTS (Clear to send)
  2328.        |   |   |
  2329.        |   |   |
  2330.        |   |   DSR (Data set ready)
  2331.        |   |
  2332.        |   |
  2333.        |   RING (phone is ringing)
  2334.        |
  2335.        |
  2336.        DCD (Data Carrier Detect)
  2337.  
  2338.   cdCTS      = $01;                 { delta-clear to send          }
  2339.   cdDSR      = $02;                 { delta-Data Set Ready         }
  2340.   cdRI       = $04;                 { delta-Ring                   }
  2341.   cdDCD      = $08;                 { delta-Data Carrier Detect    }
  2342.   cCTS       = $10;                 { Clear to send                }
  2343.   cDSR       = $20;                 { Data Set Ready               }
  2344.   cRI        = $40;                 { Ring Indicator               }
  2345.   cDCD       = $80;                 { Data Carrier Detect          }
  2346.  
  2347.  
  2348.  
  2349. [SEE-ALSO]
  2350.  
  2351. [EXAMPLE]
  2352.  
  2353. -*)
  2354.  
  2355. Function  VSerGetModemStatus(        Chan        : TSerHandle    ) : WORD;
  2356.  
  2357. BEGIN
  2358.  
  2359.   If Chan^.Sig = $CBAD Then
  2360.  
  2361.     With Chan^ Do
  2362.     BEGIN
  2363.  
  2364.       SDP.Func      := SDFGetModemStatus;
  2365.       SDP.Status    := 0;
  2366.  
  2367.       SerDriverProc( @SDP );
  2368.  
  2369.       VSerGetModemStatus := SDP.Status And $00FF;
  2370.  
  2371.     END  { With Chan^ }
  2372.  
  2373.   Else
  2374.     VSerGetModemStatus := $FFFF;
  2375.  
  2376. END;
  2377.  
  2378. {───────────────────────────────────────────────────────────────────────────}
  2379.  
  2380. (*-
  2381.  
  2382. [FUNCTION]
  2383.  
  2384. Function  VSerGetStatus(            Chan        : TSerHandle    ) : LONGINT;
  2385.  
  2386. [PARAMETERS]
  2387.  
  2388. Chan        Serial channel handle
  2389.  
  2390. [RETURNS]
  2391.  
  2392. The line and modem status values of the specified serial channel.
  2393.  
  2394. [DESCRIPTION]
  2395.  
  2396. This function obtains and returns both the line and modem status
  2397. values of the specified serial channel.
  2398.  
  2399. The modem status is in the lowest byte (0), and the modem status
  2400. is in the next highest byte (1).  The upper two-bytes are currently
  2401. unused.
  2402.  
  2403. [SEE-ALSO]
  2404.  
  2405. [EXAMPLE]
  2406.  
  2407. -*)
  2408.  
  2409. Function  VSerGetStatus(            Chan        : TSerHandle    ) : LONGINT;
  2410.  
  2411. BEGIN
  2412.  
  2413.   If Chan^.Sig = $CBAD Then
  2414.  
  2415.     With Chan^ Do
  2416.     BEGIN
  2417.  
  2418.       SDP.Func      := SDFGetBothStatus;
  2419.       SDP.Status    := 0;
  2420.  
  2421.       SerDriverProc( @SDP );
  2422.  
  2423.       VSerGetStatus := SDP.Status;
  2424.  
  2425.     END  { With Chan^ }
  2426.  
  2427.   Else
  2428.     VSerGetStatus := -1;
  2429.  
  2430. END;  { VSerGetStatus }
  2431.  
  2432. (*-
  2433.  
  2434. [FUNCTION]
  2435.  
  2436. Function VSerGetStatusBit(          Chan        : TSerHandle;
  2437.                                     Bit         : BYTE          ) : BOOLEAN;
  2438.  
  2439. [PARAMETERS]
  2440.  
  2441. Chan        Serial channel handle
  2442. Bit         Bit # to test
  2443.  
  2444. [RETURNS]
  2445.  
  2446. Whether the specified "bit" in the combined line/modem status value
  2447. is set.
  2448.  
  2449. [DESCRIPTION]
  2450.  
  2451. This function gets the current combined status-word and tests
  2452. the specified bit in that word to see if it is set.  If the bit
  2453. is set, this function returns TRUE.  Otherwise it returns FALSE.
  2454.  
  2455. [SEE-ALSO]
  2456.  
  2457. [EXAMPLE]
  2458.  
  2459. -*)
  2460.  
  2461. Function VSerGetStatusBit(          Chan        : TSerHandle;
  2462.                                     Bit         : BYTE          ) : BOOLEAN;
  2463.  
  2464. BEGIN
  2465.  
  2466.   VSerGetStatusBit := ( VSerGetStatus( Chan ) AND CBitMapL[Bit] ) <> 0;
  2467.  
  2468. END;  { VSerGetStatusBit }
  2469.  
  2470. {────────────────────────────────────────────────────────────────────────────}
  2471.  
  2472. (*-
  2473.  
  2474. [FUNCTION]
  2475.  
  2476. Function  VSerCarrier(              Chan        : TSerHandle    ) : BOOLEAN;
  2477.  
  2478. [PARAMETERS]
  2479.  
  2480. Chan        Serial channel handle
  2481.  
  2482. [RETURNS]
  2483.  
  2484. TRUE if a carrier is detected on the specified serial channel,
  2485. FALSE if a carrier is NOT detected.
  2486.  
  2487. [DESCRIPTION]
  2488.  
  2489. This function checks to see if a data carrier is present on the
  2490. specified serial channel.
  2491.  
  2492. [SEE-ALSO]
  2493.  
  2494. [EXAMPLE]
  2495.  
  2496.   IF VSerCarrier( MyChan ) Then
  2497.     WriteLN( 'Carrier is present.')
  2498.   Else
  2499.     WRiteLn( 'Carrier is NOT present.');
  2500.  
  2501. -*)
  2502.  
  2503. Function  VSerCarrier(              Chan        : TSerHandle    ) : BOOLEAN;
  2504.  
  2505. BEGIN
  2506.  
  2507.   VSerCarrier := VSerGetStatusBit( Chan, sbf_MSRcd );
  2508.  
  2509. END;  { VSerCarrier }
  2510.  
  2511. {────────────────────────────────────────────────────────────────────────────}
  2512.  
  2513. (*-
  2514.  
  2515. [FUNCTION]
  2516.  
  2517. Function  VSerRing(                 Chan        : TSerHandle    ) : BOOLEAN;
  2518.  
  2519. [PARAMETERS]
  2520.  
  2521. Chan        Serial channel handle
  2522.  
  2523. [RETURNS]
  2524.  
  2525. TRUE if the a RING is detected on the specified serial channel,
  2526. FALSE if a RING is not detected.
  2527.  
  2528. [DESCRIPTION]
  2529.  
  2530. [SEE-ALSO]
  2531.  
  2532. [EXAMPLE]
  2533.  
  2534. -*)
  2535.  
  2536. Function  VSerRing(                 Chan        : TSerHandle    ) : BOOLEAN;
  2537.  
  2538. BEGIN
  2539.  
  2540.   VSerRing := VSerGetStatusBit( Chan, sbf_MSRri );
  2541.  
  2542. END;  { VSerRing }
  2543.  
  2544. {────────────────────────────────────────────────────────────────────────────}
  2545.  
  2546. (*-
  2547.  
  2548. [FUNCTION]
  2549.  
  2550. Function  VSerInAvail(              Chan        : TSerHandle    ) : BOOLEAN;
  2551.  
  2552. [PARAMETERS]
  2553.  
  2554. Chan        Serial channel handle
  2555.  
  2556. [RETURNS]
  2557.  
  2558. TRUE if characaters are available to be read from the specified channel,
  2559. FALSE if no characters are currently available.
  2560.  
  2561. [DESCRIPTION]
  2562.  
  2563. [SEE-ALSO]
  2564.  
  2565. [EXAMPLE]
  2566.  
  2567. -*)
  2568.  
  2569. Function  VSerInAvail(              Chan        : TSerHandle    ) : BOOLEAN;
  2570.  
  2571. BEGIN
  2572.  
  2573.   VSerInAvail := VSerGetStatusBit( Chan, sbf_LSRRcvReady );
  2574.  
  2575. END;  { VSerInAvail }
  2576.  
  2577. {────────────────────────────────────────────────────────────────────────────}
  2578.  
  2579. (*-
  2580.  
  2581. [FUNCTION]
  2582.  
  2583. Function  VSerInFull(               Chan        : TSerHandle    ) : BOOLEAN;
  2584.  
  2585. [PARAMETERS]
  2586.  
  2587. Chan        Serial channel handle
  2588.  
  2589. [RETURNS]
  2590.  
  2591. TRUE if the input/read buffer for the specified channel is FULL,
  2592. FALSE if it is not FULL (IE: their is room for more characters)
  2593.  
  2594. [DESCRIPTION]
  2595.  
  2596. [SEE-ALSO]
  2597.  
  2598. [EXAMPLE]
  2599.  
  2600. -*)
  2601.  
  2602. Function  VSerInFull(               Chan        : TSerHandle    ) : BOOLEAN;
  2603.  
  2604. BEGIN
  2605.  
  2606.   VSerInFull := VSerGetStatusBit( Chan, sbf_LSROverrun );
  2607.  
  2608. END;  { VSerInFull }
  2609.  
  2610. {────────────────────────────────────────────────────────────────────────────}
  2611.  
  2612. (*-
  2613.  
  2614. [FUNCTION]
  2615.  
  2616. Function  VSerOutReady(             Chan        : TSerHandle    ) : BOOLEAN;
  2617.  
  2618. [PARAMETERS]
  2619.  
  2620. Chan        Serial channel handle
  2621.  
  2622. [RETURNS]
  2623.  
  2624. TRUE if serial port/driver/buffer is ready to accept more characters
  2625. to write/send out,
  2626.  
  2627. FALSE if they are not.
  2628.  
  2629. [DESCRIPTION]
  2630.  
  2631. [SEE-ALSO]
  2632.  
  2633. [EXAMPLE]
  2634.  
  2635. -*)
  2636.  
  2637. Function  VSerOutReady(             Chan        : TSerHandle    ) : BOOLEAN;
  2638.  
  2639. BEGIN
  2640.  
  2641.   VSerOutReady := VSerGetStatusBit( Chan, sbf_LSRXhReady );
  2642.  
  2643. END;  { VSerOutReady }
  2644.  
  2645. {────────────────────────────────────────────────────────────────────────────}
  2646.  
  2647. (*-
  2648.  
  2649. [FUNCTION]
  2650.  
  2651. Function  VSerOutEmpty(             Chan        : TSerHandle    ) : BOOLEAN;
  2652.  
  2653. [PARAMETERS]
  2654.  
  2655. Chan        Serial channel handle
  2656.  
  2657. [RETURNS]
  2658.  
  2659. TRUE if the output buffer for the specified serial channel is empty,
  2660. FALSE if it is not (1 or more characters are in the output buffer)
  2661.  
  2662. [DESCRIPTION]
  2663.  
  2664. [SEE-ALSO]
  2665.  
  2666. [EXAMPLE]
  2667.  
  2668. -*)
  2669.  
  2670. Function  VSerOutEmpty(             Chan        : TSerHandle    ) : BOOLEAN;
  2671.  
  2672. BEGIN
  2673.  
  2674.   VSerOutEmpty := VSerGetStatusBit( Chan, sbf_LSRXsReady );
  2675.  
  2676. END;  { VSerOutEmpty }
  2677.  
  2678.  
  2679. {───────────────────────────────────────────────────────────────────────────}
  2680. {                                                                           }
  2681. {         L I N E  /  M O D E M    C H A N G E     F U N C T I O N S        }
  2682. {                                                                           }
  2683. {───────────────────────────────────────────────────────────────────────────}
  2684.  
  2685.  
  2686. (*-
  2687.  
  2688. [FUNCTION]
  2689.  
  2690. Function  VSerTurnBreakOn(          Chan        : TSerHandle    ) : TError;
  2691.  
  2692. [PARAMETERS]
  2693.  
  2694. Chan        Serial channel handle
  2695.  
  2696. [RETURNS]
  2697.  
  2698. 0 if successfull, otherwise a serial error value.
  2699.  
  2700. [DESCRIPTION]
  2701.  
  2702. This function turns BREAK on on the port connected to the specified
  2703. serial channel.
  2704.  
  2705. [SEE-ALSO]
  2706.  
  2707. [EXAMPLE]
  2708.  
  2709.   Err := VSerTurnBreakOn( MyChan );
  2710.  
  2711. -*)
  2712.  
  2713. Function  VSerTurnBreakOn(          Chan        : TSerHandle    ) : TError;
  2714.  
  2715. BEGIN
  2716.  
  2717.   If Chan^.Sig = $CBAD Then
  2718.  
  2719.     With Chan^ Do
  2720.     BEGIN
  2721.  
  2722.       SDP.Func      := SDFBreakOnOff;
  2723.       SDP.OnOff     := TRUE;
  2724.       SDP.Status    := 0;
  2725.  
  2726.       SerDriverProc( @SDP );
  2727.  
  2728.       VSerTurnBreakOn := SDP.Error;
  2729.  
  2730.     END  { With Chan^ }
  2731.  
  2732.   Else
  2733.     VSerTurnBreakOn := $FBAD;
  2734.  
  2735. END;  { VSerTurnBreakOn }
  2736.  
  2737. {────────────────────────────────────────────────────────────────────────────}
  2738.  
  2739. (*-
  2740.  
  2741. [FUNCTION]
  2742.  
  2743. Function  VSerTurnBreakOff(         Chan        : TSerHandle    ) : TError;
  2744.  
  2745. [PARAMETERS]
  2746.  
  2747. Chan        Serial channel handle
  2748.  
  2749. [RETURNS]
  2750.  
  2751. 0 if successfull, otherwise a serial error value.
  2752.  
  2753. [DESCRIPTION]
  2754.  
  2755. This function turns BREAK OFF on the port connected to the specified
  2756. serial channel.
  2757.  
  2758. [SEE-ALSO]
  2759.  
  2760. [EXAMPLE]
  2761.  
  2762.   Err := VSerTurnBreakOff( MyChan );
  2763.  
  2764. -*)
  2765.  
  2766. Function  VSerTurnBreakOff(         Chan        : TSerHandle    ) : TError;
  2767.  
  2768. BEGIN
  2769.  
  2770.   If Chan^.Sig = $CBAD Then
  2771.  
  2772.     With Chan^ Do
  2773.     BEGIN
  2774.  
  2775.       SDP.Func      := SDFBreakOnOff;
  2776.       SDP.OnOff     := FALSE;
  2777.       SDP.Status    := 0;
  2778.  
  2779.       SerDriverProc( @SDP );
  2780.  
  2781.       VSerTurnBreakOff := SDP.Error;
  2782.  
  2783.     END  { With Chan^ }
  2784.  
  2785.   Else
  2786.     VSerTurnBreakOff := $FBAD;
  2787.  
  2788. END;  { VSerTurnBreakOff }
  2789.  
  2790. {────────────────────────────────────────────────────────────────────────────}
  2791.  
  2792. (*-
  2793.  
  2794. [FUNCTION]
  2795.  
  2796. Function  VSerBreak(                Chan        : TSerHandle;
  2797.                                     BreakLen    : LONGINT       ) : TError;
  2798.  
  2799. [PARAMETERS]
  2800.  
  2801. Chan        Serial channel handle
  2802. BreakLen    Break length, in 100s of a second.
  2803.  
  2804. [RETURNS]
  2805.  
  2806. 0 if successfull, otherwise a serial error value.
  2807.  
  2808. [DESCRIPTION]
  2809.  
  2810. This function turns BREAK on on the port connected to the specified
  2811. serial channel, leaves it on for the specified "breaklen", and then
  2812. turns BREAK off.
  2813.  
  2814. [SEE-ALSO]
  2815.  
  2816. [EXAMPLE]
  2817.  
  2818.   { turn break on for 1 second (100 100s) }
  2819.  
  2820.   Err := VSerBreak( MyChan, 100 );
  2821.  
  2822. -*)
  2823.  
  2824. Function  VSerBreak(                Chan        : TSerHandle;
  2825.                                     BreakLen    : LONGINT       ) : TError;
  2826.  
  2827. Var
  2828.  
  2829.   Err : TError;
  2830.  
  2831. BEGIN
  2832.  
  2833.   Err := VSerTurnBreakOn( Chan );
  2834.  
  2835.   { put pause code in here ^$^ }
  2836.  
  2837.   Err := VSerTurnBreakOff( Chan );
  2838.  
  2839. END;  { VSerBreak }
  2840.  
  2841. {────────────────────────────────────────────────────────────────────────────}
  2842.  
  2843. (*-
  2844.  
  2845. [FUNCTION]
  2846.  
  2847. Function  VSerTurnDTROn(            Chan        : TSerHandle    ) : TError;
  2848.  
  2849. [PARAMETERS]
  2850.  
  2851. Chan        Serial channel handle
  2852.  
  2853. [RETURNS]
  2854.  
  2855. 0 if successfull, otherwise a serial error value.
  2856.  
  2857. [DESCRIPTION]
  2858.  
  2859. This function turns DTR On on the port connected to the specified
  2860. serial channel.
  2861.  
  2862. [SEE-ALSO]
  2863.  
  2864. [EXAMPLE]
  2865.  
  2866.   Err := VSerTurnDTROn( MyChan );
  2867.  
  2868. -*)
  2869.  
  2870. Function  VSerTurnDTROn(            Chan        : TSerHandle    ) : TError;
  2871.  
  2872. BEGIN
  2873.  
  2874.   If Chan^.Sig = $CBAD Then
  2875.  
  2876.     With Chan^ Do
  2877.     BEGIN
  2878.  
  2879.       SDP.Func      := SDFDTROnOff;
  2880.       SDP.OnOff     := TRUE;
  2881.       SDP.Status    := 0;
  2882.  
  2883.       SerDriverProc( @SDP );
  2884.  
  2885.       VSerTurnDTROn := SDP.Error;
  2886.  
  2887.     END  { With Chan^ }
  2888.  
  2889.   Else
  2890.     VSerTurnDTROn := $FBAD;
  2891.  
  2892. END;  { VSerTurnDTROn }
  2893.  
  2894. {────────────────────────────────────────────────────────────────────────────}
  2895.  
  2896. (*-
  2897.  
  2898. [FUNCTION]
  2899.  
  2900. Function  VSerTurnDTROff(           Chan        : TSerHandle    ) : TError;
  2901.  
  2902. [PARAMETERS]
  2903.  
  2904. Chan        Serial channel handle
  2905.  
  2906. [RETURNS]
  2907.  
  2908. 0 if successfull, otherwise a serial error value.
  2909.  
  2910. [DESCRIPTION]
  2911.  
  2912. This function turns DTR OFF on the port connected to the specified
  2913. serial channel.
  2914.  
  2915. [SEE-ALSO]
  2916.  
  2917. [EXAMPLE]
  2918.  
  2919.   Err := VSerTurnDTROff( MyChan );
  2920.  
  2921. -*)
  2922.  
  2923. Function  VSerTurnDTROff(           Chan        : TSerHandle    ) : TError;
  2924.  
  2925. BEGIN
  2926.  
  2927.   If Chan^.Sig = $CBAD Then
  2928.  
  2929.     With Chan^ Do
  2930.     BEGIN
  2931.  
  2932.       SDP.Func      := SDFDTROnOff;
  2933.       SDP.OnOff     := FALSE;
  2934.       SDP.Status    := 0;
  2935.  
  2936.       SerDriverProc( @SDP );
  2937.  
  2938.       VSerTurnDTROff := SDP.Error;
  2939.  
  2940.     END  { With Chan^ }
  2941.  
  2942.   Else
  2943.     VSerTurnDTROff := $FBAD;
  2944.  
  2945. END;  { VSerTurnDTROff }
  2946.  
  2947. {────────────────────────────────────────────────────────────────────────────}
  2948.  
  2949. (*-
  2950.  
  2951. [FUNCTION]
  2952.  
  2953. Function  VSerTurnRTSON(            Chan        : TSerHandle    ) : TError;
  2954.  
  2955. [PARAMETERS]
  2956.  
  2957. Chan        Serial channel handle
  2958.  
  2959. [RETURNS]
  2960.  
  2961. 0 if successfull, otherwise a serial error value.
  2962.  
  2963. [DESCRIPTION]
  2964.  
  2965. This function turns RTS ON on the port connected to the specified
  2966. serial channel.
  2967.  
  2968. [SEE-ALSO]
  2969.  
  2970. [EXAMPLE]
  2971.  
  2972.   Err := VSerTurnRTSOn( MyChan );
  2973.  
  2974. -*)
  2975.  
  2976. Function  VSerTurnRTSON(            Chan        : TSerHandle    ) : TError;
  2977.  
  2978. BEGIN
  2979.  
  2980.   If Chan^.Sig = $CBAD Then
  2981.  
  2982.     With Chan^ Do
  2983.     BEGIN
  2984.  
  2985.       SDP.Func      := SDFRTSOnOff;
  2986.       SDP.OnOff     := TRUE;
  2987.       SDP.Status    := 0;
  2988.  
  2989.       SerDriverProc( @SDP );
  2990.  
  2991.       VSerTurnRTSOn := SDP.Error;
  2992.  
  2993.     END  { With Chan^ }
  2994.  
  2995.   Else
  2996.     VSerTurnRTSOn := $FBAD;
  2997.  
  2998. END;
  2999.  
  3000. {────────────────────────────────────────────────────────────────────────────}
  3001.  
  3002. (*-
  3003.  
  3004. [FUNCTION]
  3005.  
  3006. Function  VSerTurnRTSOff(           Chan        : TSerHandle    ) : TError;
  3007.  
  3008. [PARAMETERS]
  3009.  
  3010. Chan        Serial channel handle
  3011.  
  3012. [RETURNS]
  3013.  
  3014. 0 if successfull, otherwise a serial error value.
  3015.  
  3016. [DESCRIPTION]
  3017.  
  3018. This function turns RTS OFF on the port connected to the specified
  3019. serial channel.
  3020.  
  3021. [SEE-ALSO]
  3022.  
  3023. [EXAMPLE]
  3024.  
  3025.   Err := VSerTurnRTSOff( MyChan );
  3026.  
  3027. -*)
  3028.  
  3029. Function  VSerTurnRTSOff(           Chan        : TSerHandle    ) : TError;
  3030.  
  3031.  
  3032. BEGIN
  3033.  
  3034.   If Chan^.Sig = $CBAD Then
  3035.  
  3036.     With Chan^ Do
  3037.     BEGIN
  3038.  
  3039.       SDP.Func      := SDFRTSOnOff;
  3040.       SDP.OnOff     := FALSE;
  3041.       SDP.Status    := 0;
  3042.  
  3043.       SerDriverProc( @SDP );
  3044.  
  3045.       VSerTurnRTSOff := SDP.Error;
  3046.  
  3047.     END  { With Chan^ }
  3048.  
  3049.   Else
  3050.     VSerTurnRTSOff := $FBAD;
  3051.  
  3052. END;
  3053.  
  3054.  
  3055. {───────────────────────────────────────────────────────────────────────────}
  3056. {                                                                           }
  3057. {          B U F F E R    C O N T R O L    F U N C T I O N S                }
  3058. {                                                                           }
  3059. {───────────────────────────────────────────────────────────────────────────}
  3060.  
  3061. (*-
  3062.  
  3063. [FUNCTION]
  3064.  
  3065. Function  VSerFlushOutBuff(       Chan        : TSerHandle    ): TError;
  3066.  
  3067. [PARAMETERS]
  3068.  
  3069. Chan        Serial channel handle
  3070.  
  3071. [RETURNS]
  3072.  
  3073. 0 if successfull, otherwise a serial error value.
  3074.  
  3075. [DESCRIPTION]
  3076.  
  3077. This function flushes the output buffer associated with the
  3078. specified serial channel.  All buffered output characters will be sent
  3079. out over the port.
  3080.  
  3081. [SEE-ALSO]
  3082.  
  3083. [EXAMPLE]
  3084.  
  3085. -*)
  3086.  
  3087. Function  VSerFlushOutBuff(       Chan        : TSerHandle    ): TError;
  3088.  
  3089. BEGIN
  3090.  
  3091.  
  3092.   If Chan^.Sig = $CBAD Then
  3093.  
  3094.     With Chan^ Do
  3095.     BEGIN
  3096.  
  3097.       SDP.Func      := SDFFlushOutBuff;
  3098.       SDP.Status    := 0;
  3099.  
  3100.       SerDriverProc( @SDP );
  3101.  
  3102.       VSerFlushOutBuff :=  SDP.Error;
  3103.  
  3104.     END  { With Chan^ }
  3105.  
  3106.   Else
  3107.     VSerFlushOutBuff := $FBAD;
  3108.  
  3109. END;  { VSerFlushOutBuff }
  3110.  
  3111. {────────────────────────────────────────────────────────────────────────────}
  3112.  
  3113. (*-
  3114.  
  3115. [FUNCTION]
  3116.  
  3117. Function  VSerPurgeOutBuff(       Chan        : TSerHandle    ): TError;
  3118.  
  3119. [PARAMETERS]
  3120.  
  3121. Chan        Serial channel handle
  3122.  
  3123. [RETURNS]
  3124.  
  3125. 0 if successfull, otherwise a serial error value.
  3126.  
  3127. [DESCRIPTION]
  3128.  
  3129. This function purges the output buffer associated with the
  3130. specified serial channel.  All buffered output characters will be
  3131. disposed of, without sending it out the serial port.
  3132.  
  3133. [SEE-ALSO]
  3134.  
  3135. [EXAMPLE]
  3136.  
  3137. -*)
  3138.  
  3139. Function  VSerPurgeOutBuff(       Chan        : TSerHandle    ): TError;
  3140.  
  3141. BEGIN
  3142.  
  3143.   If Chan^.Sig = $CBAD Then
  3144.  
  3145.     With Chan^ Do
  3146.     BEGIN
  3147.  
  3148.       SDP.Func      := SDFPurgeOutBuff;
  3149.       SDP.Status    := 0;
  3150.  
  3151.       SerDriverProc( @SDP );
  3152.  
  3153.       VSerPurgeOutBuff := SDP.Error;
  3154.  
  3155.     END  { With Chan^ }
  3156.  
  3157.   Else
  3158.     VSerPurgeOutBuff := $FBAD;
  3159.  
  3160. END;  { VSerPurgeOutBuff }
  3161.  
  3162. {────────────────────────────────────────────────────────────────────────────}
  3163.  
  3164. (*-
  3165.  
  3166. [FUNCTION]
  3167.  
  3168. Function  VSerPurgeInBuff(        Chan        : TSerHandle    ): TError;
  3169.  
  3170. [PARAMETERS]
  3171.  
  3172. Chan        Serial channel handle
  3173.  
  3174. [RETURNS]
  3175.  
  3176. 0 if successfull, otherwise a serial error value.
  3177.  
  3178. [DESCRIPTION]
  3179.  
  3180. This function puges the input buffer associated with the specified
  3181. serial channel.  All buffered characers (not yet read) will be
  3182. disposed of.
  3183.  
  3184. [SEE-ALSO]
  3185.  
  3186. [EXAMPLE]
  3187.  
  3188. -*)
  3189.  
  3190. Function  VSerPurgeInBuff(        Chan        : TSerHandle    ): TError;
  3191.  
  3192. BEGIN
  3193.  
  3194.   If Chan^.Sig = $CBAD Then
  3195.  
  3196.     With Chan^ Do
  3197.     BEGIN
  3198.  
  3199.       SDP.Func      := SDFPurgeInBuff;
  3200.       SDP.Status    := 0;
  3201.  
  3202.       SerDriverProc( @SDP );
  3203.  
  3204.       VSerPurgeInBuff := SDP.Error;
  3205.  
  3206.     END  { With Chan^ }
  3207.  
  3208.   Else
  3209.     VSerPurgeInBuff := $FBAD;
  3210.  
  3211. END;  { VSerPurgeInBuff }
  3212.  
  3213. {────────────────────────────────────────────────────────────────────────────}
  3214.  
  3215. (*-
  3216.  
  3217. [FUNCTION]
  3218.  
  3219. Function  VSerGetInBuffInfo(        Chan        : TSerHandle;
  3220.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  3221.  
  3222. [PARAMETERS]
  3223.  
  3224. Chan        Serial channel handle
  3225. BuffInfo    pointer to a variable of the type TSerBuffInfo
  3226.  
  3227. [RETURNS]
  3228.  
  3229. 0 if successfull, otherwise a serial error value.
  3230.  
  3231. BuffInfo    filled in.
  3232.  
  3233. [DESCRIPTION]
  3234.  
  3235. This function obtains information about the input (read) buffer
  3236. associated with the specified serial channel.
  3237.  
  3238.   TSerBuffInfo = RECORD
  3239.  
  3240.     Size       : LONGINT;         { size of the buffer, in bytes         }
  3241.     Used       : LONGINT;         { # of bytes which are used            }
  3242.     Free       : LONGINT;         { # of bytes which are free            }
  3243.  
  3244.     Changeable : BOOLEAN;         { TRUE if the buffer size is changeable}
  3245.  
  3246.   END;
  3247.  
  3248. [SEE-ALSO]
  3249.  
  3250. [EXAMPLE]
  3251.  
  3252. -*)
  3253.  
  3254. Function  VSerGetInBuffInfo(        Chan        : TSerHandle;
  3255.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  3256.  
  3257. BEGIN
  3258.  
  3259.   If Chan^.Sig = $CBAD Then
  3260.  
  3261.     With Chan^ Do
  3262.     BEGIN
  3263.  
  3264.       SDP.Func      := SDFGetInBuffInfo;
  3265.       SDP.Status    := 0;
  3266.  
  3267.       SerDriverProc( @SDP );
  3268.  
  3269.       BuffInfo^ := SDP.BuffInfo;
  3270.  
  3271.       VSerGetInBuffInfo := SDP.Error;
  3272.  
  3273.     END  { With Chan^ }
  3274.  
  3275.   Else
  3276.     VSerGetInBuffInfo := $FBAD;
  3277.  
  3278. END;
  3279.  
  3280. {────────────────────────────────────────────────────────────────────────────}
  3281.  
  3282. (*-
  3283.  
  3284. [FUNCTION]
  3285.  
  3286. Function  VSerSetInBuffInfo(        Chan        : TSerHandle;
  3287.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  3288.  
  3289. [PARAMETERS]
  3290.  
  3291. Chan        Serial channel handle
  3292. BuffInfo    pointer to a variable of the type TSerBuffInfo
  3293.  
  3294. [RETURNS]
  3295.  
  3296. 0 if successfull, otherwise a serial error value.
  3297.  
  3298. [DESCRIPTION]
  3299.  
  3300. This function sets the ...
  3301.  
  3302.   TSerBuffInfo = RECORD
  3303.  
  3304.     Size       : LONGINT;         { size of the buffer, in bytes         }
  3305.     Used       : LONGINT;         { # of bytes which are used            }
  3306.     Free       : LONGINT;         { # of bytes which are free            }
  3307.  
  3308.     Changeable : BOOLEAN;         { TRUE if the buffer size is changeable}
  3309.  
  3310.   END;
  3311.  
  3312. [SEE-ALSO]
  3313.  
  3314. [EXAMPLE]
  3315.  
  3316. -*)
  3317.  
  3318. Function  VSerSetInBuffInfo(        Chan        : TSerHandle;
  3319.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  3320.  
  3321. BEGIN
  3322.  
  3323.   If Chan^.Sig = $CBAD Then
  3324.  
  3325.     With Chan^ Do
  3326.     BEGIN
  3327.  
  3328.       SDP.Func      := SDFSetInBuffInfo;
  3329.       SDP.BuffInfo  := BuffInfo^;
  3330.       SDP.Status    := 0;
  3331.  
  3332.       SerDriverProc( @SDP );
  3333.  
  3334.       VSerSetInBuffInfo := SDP.Error;
  3335.  
  3336.     END  { With Chan^ }
  3337.  
  3338.   Else
  3339.     VSerSetInBuffInfo := $FBAD;
  3340.  
  3341.  
  3342. END;
  3343.  
  3344. {────────────────────────────────────────────────────────────────────────────}
  3345.  
  3346. (*-
  3347.  
  3348. [FUNCTION]
  3349.  
  3350. Function  VSerGetOutBuffInfo(       Chan        : TSerHandle;
  3351.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  3352.  
  3353. [PARAMETERS]
  3354.  
  3355. Chan        Serial channel handle
  3356. BuffInfo    pointer to a variable of the type TSerBuffInfo
  3357.  
  3358. [RETURNS]
  3359.  
  3360. 0 if successfull, otherwise a serial error value.
  3361.  
  3362. BuffInfo    filled in.
  3363.  
  3364. [DESCRIPTION]
  3365.  
  3366. This function obtains information about the output (write) buffer
  3367. associated with the specified serial channel.
  3368.  
  3369.   TSerBuffInfo = RECORD
  3370.  
  3371.     Size       : LONGINT;         { size of the buffer, in bytes         }
  3372.     Used       : LONGINT;         { # of bytes which are used            }
  3373.     Free       : LONGINT;         { # of bytes which are free            }
  3374.  
  3375.     Changeable : BOOLEAN;         { TRUE if the buffer size is changeable}
  3376.  
  3377.   END;
  3378.  
  3379. [SEE-ALSO]
  3380.  
  3381. [EXAMPLE]
  3382.  
  3383. -*)
  3384.  
  3385. Function  VSerGetOutBuffInfo(       Chan        : TSerHandle;
  3386.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  3387.  
  3388.  
  3389. BEGIN
  3390.  
  3391.   If Chan^.Sig = $CBAD Then
  3392.  
  3393.     With Chan^ Do
  3394.     BEGIN
  3395.  
  3396.       SDP.Func      := SDFGetOutBuffInfo;
  3397.       SDP.Status    := 0;
  3398.  
  3399.       SerDriverProc( @SDP );
  3400.  
  3401.       BuffInfo^ := SDP.BuffInfo;
  3402.  
  3403.       VSerGetOutBuffInfo := SDP.Error;
  3404.  
  3405.     END  { With Chan^ }
  3406.  
  3407.   Else
  3408.     VSerGetOutBuffInfo := $FBAD;
  3409.  
  3410. END;
  3411.  
  3412.  
  3413. {────────────────────────────────────────────────────────────────────────────}
  3414.  
  3415. (*-
  3416.  
  3417. [FUNCTION]
  3418.  
  3419. Function  VSerSetOutBuffInfo(       Chan        : TSerHandle;
  3420.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  3421.  
  3422. [PARAMETERS]
  3423.  
  3424. Chan        Serial channel handle
  3425. BuffInfo    pointer to a variable of the type TSerBuffInfo
  3426.  
  3427. [RETURNS]
  3428.  
  3429. 0 if successfull, otherwise a serial error value.
  3430.  
  3431. [DESCRIPTION]
  3432.  
  3433. This function sets the ...
  3434.  
  3435.   TSerBuffInfo = RECORD
  3436.  
  3437.     Size       : LONGINT;         { size of the buffer, in bytes         }
  3438.     Used       : LONGINT;         { # of bytes which are used            }
  3439.     Free       : LONGINT;         { # of bytes which are free            }
  3440.  
  3441.     Changeable : BOOLEAN;         { TRUE if the buffer size is changeable}
  3442.  
  3443.   END;
  3444.  
  3445. [SEE-ALSO]
  3446.  
  3447. [EXAMPLE]
  3448.  
  3449. -*)
  3450.  
  3451. Function  VSerSetOutBuffInfo(       Chan        : TSerHandle;
  3452.                                     BuffInfo    : PSerBuffInfo  ) : TError;
  3453.  
  3454.  
  3455. BEGIN
  3456.  
  3457.   If Chan^.Sig = $CBAD Then
  3458.  
  3459.     With Chan^ Do
  3460.     BEGIN
  3461.  
  3462.       SDP.Func      := SDFSetOutBuffInfo;
  3463.       SDP.BuffInfo  := BuffInfo^;
  3464.       SDP.Status    := 0;
  3465.  
  3466.       SerDriverProc( @SDP );
  3467.  
  3468.       VSerSetOutBuffInfo := SDP.Error;
  3469.  
  3470.     END  { With Chan^ }
  3471.  
  3472.   Else
  3473.     VSerSetOutBuffInfo := $FBAD;
  3474.  
  3475. END;
  3476.  
  3477. {────────────────────────────────────────────────────────────────────────────}
  3478.  
  3479. (*-
  3480.  
  3481. [FUNCTION]
  3482.  
  3483. Function  VSerGetInAvail(           Chan        : TSerHandle    ) : LONGINT;
  3484.  
  3485. [PARAMETERS]
  3486.  
  3487. Chan        Serial channel handle
  3488.  
  3489. [RETURNS]
  3490.  
  3491. -1 if an error occurred,
  3492. otherwise returns a count of bytes available for input/read.
  3493.  
  3494. [DESCRIPTION]
  3495.  
  3496. This function returns a count of the # of bytes that are currently
  3497. in and can be read from the input buffer.
  3498.  
  3499. [SEE-ALSO]
  3500.  
  3501. [EXAMPLE]
  3502.  
  3503. -*)
  3504.  
  3505. Function  VSerGetInAvail(           Chan        : TSerHandle    ) : LONGINT;
  3506.  
  3507. BEGIN
  3508.  
  3509.   If Chan^.Sig = $CBAD Then
  3510.  
  3511.     With Chan^ Do
  3512.     BEGIN
  3513.  
  3514.       SDP.Func      := SDFGetInBuffInfo;
  3515.       SDP.Status    := 0;
  3516.  
  3517.       SerDriverProc( @SDP );
  3518.  
  3519.       If SDP.Error=0 Then
  3520.         VSerGetInAvail := SDP.BuffInfo.Used
  3521.       Else
  3522.         VSerGetInAvail := -1;
  3523.  
  3524.     END  { With Chan^ }
  3525.  
  3526.   Else
  3527.     VSerGetInAvail := $FBAD;
  3528.  
  3529. END;
  3530.  
  3531.  
  3532. {────────────────────────────────────────────────────────────────────────────}
  3533.  
  3534. (*-
  3535.  
  3536. [FUNCTION]
  3537.  
  3538. Function  VSerGetOutFree(           Chan        : TSerHandle    ) : LONGINT;
  3539.  
  3540. [PARAMETERS]
  3541.  
  3542. Chan        Serial channel handle
  3543.  
  3544. [RETURNS]
  3545.  
  3546. -1 if an error occurred,
  3547. otherwise returns a count of bytes available for buffered output/writes.
  3548.  
  3549. [DESCRIPTION]
  3550.  
  3551. This function returns a count of the # of bytes that are currently
  3552. available to store buffered output/write information.
  3553.  
  3554. [SEE-ALSO]
  3555.  
  3556. [EXAMPLE]
  3557.  
  3558. -*)
  3559.  
  3560. Function  VSerGetOutFree(           Chan        : TSerHandle    ) : LONGINT;
  3561.  
  3562. BEGIN
  3563.  
  3564.   If Chan^.Sig = $CBAD Then
  3565.  
  3566.     With Chan^ Do
  3567.     BEGIN
  3568.  
  3569.       SDP.Func      := SDFGetOutBuffInfo;
  3570.       SDP.Status    := 0;
  3571.  
  3572.       SerDriverProc( @SDP );
  3573.  
  3574.       If SDP.Error=0 Then
  3575.         VSerGetOutFree := SDP.BuffInfo.Free
  3576.       Else
  3577.         VSerGetOutFree := -1;
  3578.  
  3579.     END  { With Chan^ }
  3580.  
  3581.   Else
  3582.     VSerGetOutFree := $FBAD;
  3583.  
  3584.  
  3585. END;
  3586.  
  3587. {────────────────────────────────────────────────────────────────────────────}
  3588. (*
  3589. Procedure VSerEventProcNew(         Chan        : TSerHandle;
  3590.                                     Proc        : TSerEventProc;
  3591.                                     EventMask   : WORD;
  3592.                                     ProcInfo    : Pointer;
  3593.                                 Var ProcHandle  : TSerHandle    ) : TError;
  3594.  
  3595. Procedure VSerEventProcOff(         ProcHandle  : TSerHandle    );
  3596.  
  3597. Procedure VSerEventProcOn(          ProcHandle  : TSerHandle    );
  3598.  
  3599. Procedure VSerEventProcDispose(     ProcHandle  : TSerHandle    );
  3600. *)
  3601.  
  3602. {────────────────────────────────────────────────────────────────────────────}
  3603.  
  3604.  
  3605.  
  3606. (*-
  3607.  
  3608. [FUNCTION]
  3609.  
  3610. Function  VSerWriteChEx(            Chan        : TSerHandle;
  3611.                                     Flags       : WORD;
  3612.                                     OutCh       : CHAR;
  3613.                                     Timeout100s : LONGINT       ) : TError;
  3614.  
  3615. [PARAMETERS]
  3616.  
  3617. Chan        serial channel handle
  3618. flags       write flags
  3619. outch       character to write
  3620. timeout100s timeout value
  3621.  
  3622. [RETURNS]
  3623.  
  3624. 0 if successfull, otherwise a serial error value.
  3625.  
  3626. [DESCRIPTION]
  3627.  
  3628. This function writes the specified character "outch" to the specified
  3629. serial channel "chan".
  3630.  
  3631. Flags
  3632.  
  3633.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  3634.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  3635.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  3636.   csfImmediate = $02;          { Bypass read/write buffers;              }
  3637.  
  3638. TimeOut100s is a timeout value.  If no timeout is desired, this value
  3639. should be -1.  Otherwise, this function will attempt to send the
  3640. character until the timeout period elapses.
  3641.  
  3642. [SEE-ALSO]
  3643.  
  3644. [EXAMPLE]
  3645.  
  3646. -*)
  3647.  
  3648. Function  VSerWriteChEx(            Chan        : TSerHandle;
  3649.                                     Flags       : WORD;
  3650.                                     OutCh       : CHAR;
  3651.                                     Timeout100s : LONGINT       ) : TError;
  3652.  
  3653. BEGIN
  3654.  
  3655.   If Chan^.Sig = $CBAD Then
  3656.  
  3657.     With Chan^ Do
  3658.     BEGIN
  3659.  
  3660.       SDP.Func      := SDFWriteCh;
  3661.       SDP.Ch        := OutCh;
  3662.       SDP.Flags     := Flags;
  3663.       SDP.Timeout   := Timeout100s;
  3664.       SDP.Status    := 0;
  3665.  
  3666.       SerDriverProc( @SDP );
  3667.  
  3668.       VSerWriteChEx := SDP.Error;
  3669.  
  3670.     END  { With Chan^ }
  3671.  
  3672.   Else
  3673.     VSerWriteChEx := $FBAD;
  3674.  
  3675.  
  3676.  
  3677. END;
  3678.  
  3679.  
  3680. {────────────────────────────────────────────────────────────────────────────}
  3681.  
  3682.  
  3683.  
  3684. (*-
  3685.  
  3686. [FUNCTION]
  3687.  
  3688. Function  VSerWriteBlockEx(         Chan        : TSerHandle;
  3689.                                     Flags       : WORD;
  3690.                                     BuffSize    : LONGINT;
  3691.                                     BuffPtr     : POINTER;
  3692.                                     TimeOut100s : LONGINT;
  3693.                                 Var XFerCount   : LONGINT      ) : TError;
  3694.  
  3695. [PARAMETERS]
  3696.  
  3697. Chan        serial channel handle
  3698. flags       write flags
  3699. buffsize    size of the block/buffer to write
  3700. buffptr     pointer to the block/buffer to write
  3701. timeout100s timeout value
  3702. xfercount   (RETURNED) # of characters sent
  3703.  
  3704. [RETURNS]
  3705.  
  3706. 0 if successfull, otherwise a serial error value.
  3707.  
  3708. [DESCRIPTION]
  3709.  
  3710. This function writes the specified block pointer to by "buffptr" to
  3711. the specified serial channel.
  3712.  
  3713. Flags
  3714.  
  3715.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  3716.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  3717.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  3718.   csfImmediate = $02;          { Bypass read/write buffers;              }
  3719.  
  3720. TimeOut100s is a timeout value.  If no timeout is desired, this value
  3721. should be -1.  Otherwise, this function will attempt to send the
  3722. block until the timeout period elapses.
  3723.  
  3724. XFERCOUNT is filled in by this function.  It is a count of the # of
  3725. bytes from the block that were successfully sent.
  3726.  
  3727. [SEE-ALSO]
  3728.  
  3729. [EXAMPLE]
  3730.  
  3731. -*)
  3732.  
  3733.  
  3734. Function  VSerWriteBlockEx(         Chan        : TSerHandle;
  3735.                                     Flags       : WORD;
  3736.                                     BuffSize    : LONGINT;
  3737.                                     BuffPtr     : POINTER;
  3738.                                     TimeOut100s : LONGINT;
  3739.                                 Var XFerCount   : LONGINT      ) : TError;
  3740.  
  3741. BEGIN
  3742.  
  3743.   If Chan^.Sig = $CBAD Then
  3744.  
  3745.     With Chan^ Do
  3746.     BEGIN
  3747.  
  3748.       SDP.Func   := SDFWriteBlock;
  3749.       SDP.Count  := BuffSize;
  3750.       SDP.Buf    := BuffPtr;
  3751.       SDP.Flags  := Flags;
  3752.       SDP.Timeout:= TimeOut100s;
  3753.       SDP.Status := 0;
  3754.  
  3755.       SerDriverProc( @SDP );
  3756.  
  3757.       XFerCount := SDP.Result;
  3758.  
  3759.       VSerWriteBlockEx := SDP.Error;
  3760.  
  3761.     END  { With Chan^ }
  3762.  
  3763.   Else
  3764.     VSerWriteBlockEx := $FBAD;
  3765.  
  3766. END;
  3767.  
  3768.  
  3769.  
  3770. {────────────────────────────────────────────────────────────────────────────}
  3771.  
  3772.  
  3773. (*-
  3774.  
  3775. [FUNCTION]
  3776.  
  3777. Function  VSerWriteStEx(            Chan        : TSerHandle;
  3778.                                     Flags       : WORD;
  3779.                                     ST          : STRING;
  3780.                                     TimeOut100s : LONGINT;
  3781.                                 Var XFerCount   : LONGINT      ) : TError;
  3782.  
  3783. [PARAMETERS]
  3784.  
  3785. Chan        serial channel handle
  3786. flags       write flags
  3787. st          the string to write
  3788. timeout100s timeout value
  3789. xfercount   (RETURNED) # of characters sent
  3790.  
  3791. [RETURNS]
  3792.  
  3793. 0 if successfull, otherwise a serial error value.
  3794.  
  3795. [DESCRIPTION]
  3796.  
  3797. This function writes the specified string "st" to
  3798. the specified serial channel.
  3799.  
  3800. Flags
  3801.  
  3802.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  3803.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  3804.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  3805.   csfImmediate = $02;          { Bypass read/write buffers;              }
  3806.  
  3807. TimeOut100s is a timeout value.  If no timeout is desired, this value
  3808. should be -1.  Otherwise, this function will attempt to send the
  3809. string until the timeout period elapses.
  3810.  
  3811. XFERCOUNT is filled in by this function.  It is a count of the # of
  3812. bytes from the string that were successfully sent.
  3813.  
  3814. [SEE-ALSO]
  3815.  
  3816. [EXAMPLE]
  3817.  
  3818. -*)
  3819.  
  3820.  
  3821. Function  VSerWriteStEx(            Chan        : TSerHandle;
  3822.                                     Flags       : WORD;
  3823.                                     ST          : STRING;
  3824.                                     TimeOut100s : LONGINT;
  3825.                                 Var XFerCount   : LONGINT      ) : TError;
  3826.  
  3827. BEGIN
  3828.  
  3829.  
  3830.   VSerWriteStEx := VSerWriteBlockEx( Chan,
  3831.                                      Flags,
  3832.                                      Byte( ST[0] ),
  3833.                                      @ST[1],
  3834.                                      TimeOUt100s,
  3835.                                      XFerCount           );
  3836.  
  3837.  
  3838. END;
  3839.  
  3840.  
  3841.  
  3842. {────────────────────────────────────────────────────────────────────────────}
  3843.  
  3844. (*-
  3845.  
  3846. [FUNCTION]
  3847.  
  3848. Function  VSerWritePchEx(           Chan        : TSerHandle;
  3849.                                     Flags       : WORD;
  3850.                                     Pch         : PChar;
  3851.                                     TimeOut100s : LONGINT;
  3852.                                 Var XFerCount   : LONGINT     ) : TError;
  3853.  
  3854. [PARAMETERS]
  3855.  
  3856. Chan        serial channel handle
  3857. flags       write flags
  3858. Pch         pointer to a null-terminated string to write
  3859. timeout100s timeout value
  3860. xfercount   (RETURNED) # of characters sent
  3861.  
  3862. [RETURNS]
  3863.  
  3864. 0 if successfull, otherwise a serial error value.
  3865.  
  3866. [DESCRIPTION]
  3867.  
  3868. This function writes the specified null-terminated string "pch" to
  3869. the specified serial channel.
  3870.  
  3871. Flags
  3872.  
  3873.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  3874.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  3875.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  3876.   csfImmediate = $02;          { Bypass read/write buffers;              }
  3877.  
  3878. TimeOut100s is a timeout value.  If no timeout is desired, this value
  3879. should be -1.  Otherwise, this function will attempt to send the
  3880. string until the timeout period elapses.
  3881.  
  3882. XFERCOUNT is filled in by this function.  It is a count of the # of
  3883. bytes from the string that were successfully sent.
  3884.  
  3885. [SEE-ALSO]
  3886.  
  3887. [EXAMPLE]
  3888.  
  3889. -*)
  3890.  
  3891. {$IFDEF VER70}
  3892.  
  3893. Function  VSerWritePchEx(           Chan        : TSerHandle;
  3894.                                     Flags       : WORD;
  3895.                                     Pch         : PChar;
  3896.                                     TimeOut100s : LONGINT;
  3897.                                 Var XFerCount   : LONGINT     ) : TError;
  3898.  
  3899. BEGIN
  3900.  
  3901.   VSerWritePchEx := VSerWriteBlockEx( Chan,
  3902.                                       Flags,
  3903.                                       StrLen( PCh ),
  3904.                                       PCh,
  3905.                                       TimeOut100s,
  3906.                                       XFerCount        );
  3907.  
  3908. END;
  3909.  
  3910. {$ENDIF}   { !! version 6.0 bug }
  3911.  
  3912. {────────────────────────────────────────────────────────────────────────────}
  3913.  
  3914. {---}
  3915.  
  3916.  
  3917. (*-
  3918.  
  3919. [FUNCTION]
  3920.  
  3921. Function  VSerSetWriteTimeout(      Chan        : TSerHandle;
  3922.                                     TimeOut100s : LONGINT      ) : TError;
  3923.  
  3924.  
  3925. [PARAMETERS]
  3926.  
  3927. Chan        serial channel handle
  3928. timeout100s default timeout value to use
  3929.  
  3930. [RETURNS]
  3931.  
  3932. 0 if successfull, otherwise a serial error value.
  3933.  
  3934. [DESCRIPTION]
  3935.  
  3936. This function sets the default timeout value that is used for the
  3937. "non-ex" write functions (IE:  VSerWritech, VSerWriteBlock)
  3938.  
  3939. [SEE-ALSO]
  3940.  
  3941. [EXAMPLE]
  3942.  
  3943.   { set the write timeout to 2 seconds (200 100s) }
  3944.  
  3945.   Err := VSerSetWriteTimeout( MyChan, 200 );
  3946.  
  3947.   { the call below will now timeout after 2 seconds }
  3948.  
  3949.   Err := VSerWriteCh( MyChan, '!' );
  3950.  
  3951.   { set the write timeout to 30 seconds (3000 100s) }
  3952.  
  3953.   Err := VSerSetWriteTimeout( MyChan, 3000 );
  3954.  
  3955.   { the call below will now timeout after 30 seconds }
  3956.  
  3957.   Err := VSerWriteCh( MyChan, '!' );
  3958.  
  3959.  
  3960.   { Set the write timeout to NONE }
  3961.  
  3962.   Err := VSerSetWriteTimeout( MyChan, -1 );
  3963.  
  3964.   { the call below will not timeout }
  3965.  
  3966.   Err := VSerWriteCh( MyChan, '!' );
  3967.  
  3968.  
  3969. -*)
  3970.  
  3971.  
  3972. Function  VSerSetWriteTimeout(      Chan        : TSerHandle;
  3973.                                     TimeOut100s : LONGINT      ) : TError;
  3974.  
  3975. BEGIN
  3976.  
  3977.   Chan^.WriteTimeout := Timeout100s;
  3978.  
  3979. END;
  3980.  
  3981.  
  3982. {────────────────────────────────────────────────────────────────────────────}
  3983.  
  3984.  
  3985. (*-
  3986.  
  3987. [FUNCTION]
  3988.  
  3989. Function  VSerSetWriteFlags(        Chan        : TSerHandle;
  3990.                                     Flags       : WORD         ) : TError;
  3991.  
  3992.  
  3993. [PARAMETERS]
  3994.  
  3995. Chan        serial channel handle
  3996. flags       default write flags to use
  3997.  
  3998. [RETURNS]
  3999.  
  4000. 0 if successfull, otherwise a serial error value.
  4001.  
  4002. [DESCRIPTION]
  4003.  
  4004. This function sets the default "flags" value that is used for the
  4005. "non-ex" write functions (IE:  VSerWritech, VSerWriteBlock)
  4006.  
  4007. Flags
  4008.  
  4009.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  4010.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  4011.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  4012.   csfImmediate = $02;          { Bypass read/write buffers;              }
  4013.  
  4014.  
  4015. [SEE-ALSO]
  4016.  
  4017. [EXAMPLE]
  4018.  
  4019.   { set the write flags to WAIT }
  4020.  
  4021.   Err := VSerSetWriteFlags( Mychan, csfWAIT );
  4022.  
  4023.   { the call below will now wait/block until the char is sent }
  4024.  
  4025.   Err := VSerWriteCh( MyChan, '!' );
  4026.  
  4027.   { set the write flags to NOWAIT }
  4028.  
  4029.   Err := VSerSetWriteFlags( Mychan, csfNOWAIT );
  4030.  
  4031.   { the call below will now return immediately if the char can not }
  4032.   { be sent                                                        }
  4033.  
  4034.   Err := VSerWriteCh( MyChan, '!' );
  4035.  
  4036.  
  4037.  
  4038.  
  4039. -*)
  4040.  
  4041.  
  4042. Function  VSerSetWriteFlags(        Chan        : TSerHandle;
  4043.                                     Flags       : WORD         ) : TError;
  4044.  
  4045. BEGIN
  4046.  
  4047.   Chan^.WriteFlags := Chan^.WriteFlags;
  4048.  
  4049. END;
  4050.  
  4051.  
  4052. {────────────────────────────────────────────────────────────────────────────}
  4053.  
  4054.  
  4055.  
  4056. (*-
  4057.  
  4058. [FUNCTION]
  4059.  
  4060. Function  VSerGetWriteTimeout(      Chan        : TSerHandle   ) : LONGINT;
  4061.  
  4062.  
  4063. [PARAMETERS]
  4064.  
  4065. Chan        serial channel handle
  4066.  
  4067. [RETURNS]
  4068.  
  4069. current default timeout value,
  4070. -1 if an error occurred.
  4071.  
  4072. [DESCRIPTION]
  4073.  
  4074. This function obtains and returns the current default write timeout
  4075. value, which can be set via a call to VSerSetWriteTimeout.
  4076.  
  4077. The timeout value is in 100s of a second.
  4078.  
  4079. [SEE-ALSO]
  4080.  
  4081. [EXAMPLE]
  4082.  
  4083.  
  4084.   WriteLn( 'Current timeout value ........ ',
  4085.                         VSerGetWriteTimeout( MyChan ) );
  4086.  
  4087. -*)
  4088.  
  4089. Function  VSerGetWriteTimeout(      Chan        : TSerHandle   ) : LONGINT;
  4090.  
  4091. BEGIN
  4092.  
  4093.   VSerGetWriteTimeout := Chan^.WriteTimeout;
  4094.  
  4095. END;
  4096.  
  4097.  
  4098. {────────────────────────────────────────────────────────────────────────────}
  4099.  
  4100.  
  4101.  
  4102. (*-
  4103.  
  4104. [FUNCTION]
  4105.  
  4106. Function  VSerGetWriteFlags(        Chan        : TSerHandle   ) : WORD;
  4107.  
  4108.  
  4109. [PARAMETERS]
  4110.  
  4111. Chan        serial channel handle
  4112.  
  4113. [RETURNS]
  4114.  
  4115. current default write flags.
  4116.  
  4117. [DESCRIPTION]
  4118.  
  4119. This function obtains and returns the current default write flags
  4120. value, which can be set via a call to VSerSetWriteFlags.
  4121.  
  4122. The timeout value is in 100s of a second.
  4123.  
  4124. [SEE-ALSO]
  4125.  
  4126. [EXAMPLE]
  4127.  
  4128.  
  4129.   If (VSerGetWriteFlags AND csfWAIT)<>0 Then
  4130.     WriteLN('Non-EX writes will not wait until completion')
  4131.   Else
  4132.     WriteLn('Non-EX writes will wait until completion.');
  4133.  
  4134. -*)
  4135.  
  4136.  
  4137. Function  VSerGetWriteFlags(        Chan        : TSerHandle   ) : WORD;
  4138.  
  4139. BEGIN
  4140.  
  4141.   VSerGetWriteFlags := Chan^.WriteFlags;
  4142.  
  4143. END;
  4144.  
  4145.  
  4146.  
  4147. {────────────────────────────────────────────────────────────────────────────}
  4148.  
  4149. (*-
  4150.  
  4151. [FUNCTION]
  4152.  
  4153. Function  VSerWriteCh(              Chan        : TSerHandle;
  4154.                                     OutCh       : CHAR        ) : TError;
  4155.  
  4156.  
  4157. [PARAMETERS]
  4158.  
  4159. Chan        serial channel handle
  4160. outch       character to write
  4161.  
  4162. [RETURNS]
  4163.  
  4164. 0 if successfull, otherwise a serial error value.
  4165.  
  4166. [DESCRIPTION]
  4167.  
  4168. This function writes the specified character "outch" to the specified
  4169. serial channel "chan".
  4170.  
  4171. This function will use the default write flags and timeout values.
  4172. (As set by VSerSetWriteTimeout/VSerSetWriteFlags)
  4173.  
  4174. [SEE-ALSO]
  4175.  
  4176. [EXAMPLE]
  4177.  
  4178.   { write an exclamation point to the channel }
  4179.  
  4180.   Err := VSerWriteCh( MyChan, '!' );
  4181.  
  4182. -*)
  4183.  
  4184. Function  VSerWriteCh(              Chan        : TSerHandle;
  4185.                                     OutCh       : CHAR        ) : TError;
  4186.  
  4187. BEGIN
  4188.  
  4189.   VSerWriteCh := VSerWriteChEx( Chan,
  4190.                                 Chan^.Writeflags,
  4191.                                 OutCh,
  4192.                                 Chan^.WriteTimeout );
  4193.  
  4194. END;
  4195.  
  4196.  
  4197.  
  4198. {────────────────────────────────────────────────────────────────────────────}
  4199.  
  4200.  
  4201. (*-
  4202.  
  4203. [FUNCTION]
  4204.  
  4205. Function  VSerWriteBlock(           Chan        : TSerHandle;
  4206.                                     BuffSize    : LONGINT;
  4207.                                     BuffPtr     : POINTER     ) : TError;
  4208.  
  4209. [PARAMETERS]
  4210.  
  4211. Chan        serial channel handle
  4212. buffsize    size of the block/buffer to write
  4213. buffptr     pointer to the block/buffer to write
  4214.  
  4215. [RETURNS]
  4216.  
  4217. 0 if successfull, otherwise a serial error value.
  4218.  
  4219. [DESCRIPTION]
  4220.  
  4221. This function writes the specified block pointer to by "buffptr" to
  4222. the specified serial channel.
  4223.  
  4224. This function will use the default write flags and timeout values.
  4225. (As set by VSerSetWriteTimeout/VSerSetWriteFlags)
  4226.  
  4227. If an error occurs, their is no way to determine how many characters
  4228. have been sent.  If you need to know have many characters are
  4229. successfully sent, use the VSerWriteBlockEx function.
  4230.  
  4231. [SEE-ALSO]
  4232.  
  4233. [EXAMPLE]
  4234.  
  4235. -*)
  4236.  
  4237.  
  4238. Function  VSerWriteBlock(           Chan        : TSerHandle;
  4239.                                     BuffSize    : LONGINT;
  4240.                                     BuffPtr     : POINTER     ) : TError;
  4241.  
  4242. Var
  4243.  
  4244.   XFerCount : LONGINT;
  4245.  
  4246.  
  4247. BEGIN
  4248.  
  4249.   VSerWriteBlock := VSerWriteBlockEx( Chan,
  4250.                                       Chan^.WriteFlags,
  4251.                                       BuffSize,
  4252.                                       BuffPtr,
  4253.                                       Chan^.WriteTimeout,
  4254.                                       XFerCount            );
  4255.  
  4256.  
  4257. END;
  4258.  
  4259.  
  4260. {────────────────────────────────────────────────────────────────────────────}
  4261.  
  4262.  
  4263.  
  4264. (*-
  4265.  
  4266. [FUNCTION]
  4267.  
  4268. Function  VSerWriteSt(              Chan        : TSerHandle;
  4269.                                     St          : STRING      ) : TError;
  4270.  
  4271. [PARAMETERS]
  4272.  
  4273. Chan        serial channel handle
  4274. st          the string to write
  4275.  
  4276. [RETURNS]
  4277.  
  4278. 0 if successfull, otherwise a serial error value.
  4279.  
  4280. [DESCRIPTION]
  4281.  
  4282. This function writes the specified string "st" to
  4283. the specified serial channel.
  4284.  
  4285. This function will use the default write flags and timeout values.
  4286. (As set by VSerSetWriteTimeout/VSerSetWriteFlags)
  4287.  
  4288. If an error occurs, their is no way to determine how many characters
  4289. have been sent.  If you need to know have many characters are
  4290. successfully sent, use the VSerWriteStEx function.
  4291.  
  4292. [SEE-ALSO]
  4293.  
  4294. [EXAMPLE]
  4295.  
  4296.   { write a string to the channel }
  4297.  
  4298.   Err := VSerWriteSt( MyChan, 'Hello, Serial World!');
  4299.  
  4300. -*)
  4301.  
  4302.  
  4303. Function  VSerWriteSt(              Chan        : TSerHandle;
  4304.                                     St          : STRING      ) : TError;
  4305.  
  4306.  
  4307. Var
  4308.  
  4309.   XFerCount : LONGINT;
  4310.  
  4311. BEGIN
  4312.  
  4313.   VSerWriteSt := VSerWriteStEx( Chan,
  4314.                                 Chan^.WriteFlags,
  4315.                                 ST,
  4316.                                 Chan^.WriteTimeout,
  4317.                                 XFerCount               );
  4318.  
  4319. END;
  4320.  
  4321.  
  4322. {────────────────────────────────────────────────────────────────────────────}
  4323.  
  4324. (*-
  4325.  
  4326. [FUNCTION]
  4327.  
  4328. Function  VSerWritePch(             Chan        : TSerHandle;
  4329.                                     Pch         : PChar       ) : TError;
  4330.  
  4331.  
  4332. [PARAMETERS]
  4333.  
  4334. Chan        serial channel handle
  4335. Pch         pointer to a null-terminated string to write
  4336.  
  4337. [RETURNS]
  4338.  
  4339. 0 if successfull, otherwise a serial error value.
  4340.  
  4341. [DESCRIPTION]
  4342.  
  4343. This function writes the specified null-terminated string "pch" to
  4344. the specified serial channel.
  4345.  
  4346. This function will use the default write flags and timeout values.
  4347. (As set by VSerSetWriteTimeout/VSerSetWriteFlags)
  4348.  
  4349. If an error occurs, their is no way to determine how many characters
  4350. have been sent.  If you need to know have many characters are
  4351. successfully sent, use the VSerWritePchEx function.
  4352.  
  4353.  
  4354. [SEE-ALSO]
  4355.  
  4356. [EXAMPLE]
  4357.  
  4358. -*)
  4359.  
  4360. {$IFDEF VER70}
  4361.  
  4362. Function  VSerWritePch(             Chan        : TSerHandle;
  4363.                                     Pch         : PChar       ) : TError;
  4364. Var
  4365.  
  4366.   XFerCount : LONGINT;
  4367.  
  4368. BEGIN
  4369.  
  4370.   VSerWritePch := VSerWritePchEx( Chan,
  4371.                                   Chan^.WriteFlags,
  4372.                                   PCh,
  4373.                                   Chan^.WriteTimeout,
  4374.                                   XFerCount              );
  4375.  
  4376. END;
  4377.  
  4378. {$ENDIF}
  4379.  
  4380. {────────────────────────────────────────────────────────────────────────────}
  4381.  
  4382. {---}
  4383.  
  4384. (*-
  4385.  
  4386. [FUNCTION]
  4387.  
  4388. Function  VSerReadChEx(             Chan        : TSerHandle;
  4389.                                     Flags       : WORD;
  4390.                                 Var InCh        : CHAR;
  4391.                                     Timeout100s : LONGINT       ) : TError;
  4392.  
  4393. [PARAMETERS]
  4394.  
  4395. Chan        serial channel handle
  4396. flags       write flags
  4397. inch        varaible to receive the character
  4398. timeout100s timeout value
  4399.  
  4400. [RETURNS]
  4401.  
  4402. 0 if successfull, otherwise a serial error value.
  4403.  
  4404. [DESCRIPTION]
  4405.  
  4406. This function reads a characters from the specified serial channel "chan".
  4407.  
  4408. Flags
  4409.  
  4410.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  4411.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  4412.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  4413.   csfImmediate = $02;          { Bypass read/write buffers;              }
  4414.  
  4415. TimeOut100s is a timeout value.  If no timeout is desired, this value
  4416. should be -1.  Otherwise, this function will attempt to read a chracter
  4417. from the specified channel until the timeout period elapses.
  4418.  
  4419. [SEE-ALSO]
  4420.  
  4421. [EXAMPLE]
  4422.  
  4423. Var
  4424.  
  4425.   NewCh : CHAR;
  4426.  
  4427. BEGIN
  4428.  
  4429.   { read a char; wait until one is ready or 2 seconds elapse }
  4430.  
  4431.   Err := VSerReadChEx( Mychan,
  4432.                        csfWait,
  4433.                        NewCh,
  4434.                        200         );
  4435.  
  4436.   { read another char; one is ready or 2 seconds elapse }
  4437.  
  4438.   Err := VSerReadChEx( Mychan,
  4439.                        csfWait,
  4440.                        NewCh,
  4441.                        200         );
  4442.  
  4443.   { read a char; wait until one is ready  }
  4444.  
  4445.   Err := VSerReadChEx( Mychan,
  4446.                        csfWait,
  4447.                        NewCh,
  4448.                        -1        );
  4449.  
  4450.  
  4451.  
  4452.   { read a char; return immediately if none are available }
  4453.  
  4454.   Err := VSerReadChEx( Mychan,
  4455.                        csfNoWait,
  4456.                        NewCh,
  4457.                        -1        );
  4458.  
  4459.  
  4460. END;
  4461.  
  4462. -*)
  4463.  
  4464.  
  4465. Function  VSerReadChEx(             Chan        : TSerHandle;
  4466.                                     Flags       : WORD;
  4467.                                 Var InCh        : CHAR;
  4468.                                     Timeout100s : LONGINT       ) : TError;
  4469.  
  4470.  
  4471. BEGIN
  4472.  
  4473.   If Chan^.Sig = $CBAD Then
  4474.  
  4475.     With Chan^ Do
  4476.     BEGIN
  4477.  
  4478.       SDP.Func      := SDFReadCh;
  4479.       SDP.Status    := 0;
  4480.       SDP.Flags     := Flags;
  4481.       SDP.Timeout   := Timeout100s;
  4482.  
  4483.       SerDriverProc( @SDP );
  4484.  
  4485.       InCH          := SDP.Ch;
  4486.  
  4487.       VSerReadChEx  := SDP.Error;
  4488.  
  4489.     END
  4490.  
  4491.   Else
  4492.     VSerReadChEx := $FBAD;
  4493.  
  4494.  
  4495.  
  4496. END;
  4497.  
  4498.  
  4499. {────────────────────────────────────────────────────────────────────────────}
  4500.  
  4501. (*-
  4502.  
  4503. [FUNCTION]
  4504.  
  4505.  
  4506. Function  VSerReadBlockEx(          Chan        : TSerHandle;
  4507.                                     Flags       : WORD;
  4508.                                     BuffSize    : LONGINT;
  4509.                                     BuffPtr     : POINTER;
  4510.                                     TimeOut100s : LONGINT;
  4511.                                 Var XFerCount   : LONGINT      ) : TError;
  4512.  
  4513. [PARAMETERS]
  4514.  
  4515. Chan        serial channel handle
  4516. flags       write flags
  4517. buffsize    size of the block/buffer to read into
  4518. buffptr     pointer to the block/buffer to read into
  4519. timeout100s timeout value
  4520. xfercount   (RETURNED) # of characters read
  4521.  
  4522. [RETURNS]
  4523.  
  4524. 0 if successfull, otherwise a serial error value.
  4525.  
  4526. [DESCRIPTION]
  4527.  
  4528. This function reads into the specified buffer pointed to by "buffptr" from
  4529. the specified serial channel.
  4530.  
  4531. Flags
  4532.  
  4533.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  4534.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  4535.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  4536.   csfImmediate = $02;          { Bypass read/write buffers;              }
  4537.  
  4538. TimeOut100s is a timeout value.  If no timeout is desired, this value
  4539. should be -1.  Otherwise, this function will attempt to read into the
  4540. buffer until the timeout period elapses or the specified buffer is
  4541. filled.
  4542.  
  4543. XFERCOUNT is filled in by this function.  It is a count of the # of
  4544. bytes that were succesfully read into the buffer.
  4545.  
  4546. [SEE-ALSO]
  4547.  
  4548. [EXAMPLE]
  4549.  
  4550. -*)
  4551.  
  4552.  
  4553.  
  4554. Function  VSerReadBlockEx(          Chan        : TSerHandle;
  4555.                                     Flags       : WORD;
  4556.                                     BuffSize    : LONGINT;
  4557.                                     BuffPtr     : POINTER;
  4558.                                     TimeOut100s : LONGINT;
  4559.                                 Var XFerCount   : LONGINT      ) : TError;
  4560.  
  4561. BEGIN
  4562.  
  4563.  
  4564.   If Chan^.Sig = $CBAD Then
  4565.  
  4566.     With Chan^ Do
  4567.     BEGIN
  4568.  
  4569.       SDP.Func   := SDFReadBlock;
  4570.       SDP.Count  := BuffSize;
  4571.       SDP.Buf    := BuffPtr;
  4572.       SDP.Flags  := Flags;
  4573.       SDP.Timeout:= Timeout100s;
  4574.       SDP.Status := 0;
  4575.  
  4576.       SerDriverProc( @SDP );
  4577.  
  4578.       XFerCount       := SDP.Result;
  4579.  
  4580.       VSerReadBlockEx := SDP.Error;
  4581.  
  4582.     END  { With Chan^ }
  4583.  
  4584.   Else
  4585.     VSerReadBlockEx := $FBAD;
  4586.  
  4587.  
  4588. END;
  4589.  
  4590.  
  4591. {────────────────────────────────────────────────────────────────────────────}
  4592.  
  4593.  
  4594. (*-
  4595.  
  4596. [FUNCTION]
  4597.  
  4598. Function  VSerReadStEx(             Chan        : TSerHandle;
  4599.                                     Flags       : WORD;
  4600.                                     STSize      : WORD;
  4601.                                 Var ST          : STRING;
  4602.                                     TimeOut100s : LONGINT      ) : TError;
  4603.  
  4604.  
  4605. [PARAMETERS]
  4606.  
  4607. Chan        serial channel handle
  4608. flags       write flags
  4609. stsize      maximum size of the string to read into
  4610. st          string to read into
  4611. timeout100s timeout value
  4612. xfercount   (RETURNED) # of characters read
  4613.  
  4614. [RETURNS]
  4615.  
  4616. 0 if successfull, otherwise a serial error value.
  4617.  
  4618. [DESCRIPTION]
  4619.  
  4620. This function reads into the specified string for up to "STsize"
  4621. characters.
  4622.  
  4623. Flags
  4624.  
  4625.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  4626.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  4627.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  4628.   csfImmediate = $02;          { Bypass read/write buffers;              }
  4629.  
  4630. TimeOut100s is a timeout value.  If no timeout is desired, this value
  4631. should be -1.  Otherwise, this function will attempt to read into the
  4632. string until the timeout period elapses or the specified "Stsize" # of
  4633. bytes has been read.
  4634.  
  4635. XFERCOUNT is filled in by this function.  It is a count of the # of
  4636. bytes that were succesfully read into the string.
  4637.  
  4638. [SEE-ALSO]
  4639.  
  4640. [EXAMPLE]
  4641.  
  4642. -*)
  4643.  
  4644.  
  4645. Function  VSerReadStEx(             Chan        : TSerHandle;
  4646.                                     Flags       : WORD;
  4647.                                     STSize      : WORD;
  4648.                                 Var ST          : STRING;
  4649.                                     TimeOut100s : LONGINT      ) : TError;
  4650.  
  4651. BEGIN
  4652.  
  4653.  
  4654.   If Chan^.Sig = $CBAD Then
  4655.  
  4656.     With Chan^ Do
  4657.     BEGIN
  4658.  
  4659.       SDP.Func   := SDFReadBlock;
  4660.       SDP.Count  := STSize;
  4661.       SDP.Buf    := @ST[1];
  4662.       SDP.Flags  := Flags;
  4663.       SDP.Timeout:= Timeout100s;
  4664.       SDP.Status := 0;
  4665.  
  4666.       SerDriverProc( @SDP );
  4667.  
  4668.       Byte( ST[0] ) := SDP.Result;
  4669.  
  4670.       VSerReadStEx := SDP.Error;
  4671.  
  4672.     END  { With Chan^ }
  4673.  
  4674.   Else
  4675.     VSerReadStEx := $FBAD;
  4676.  
  4677. END;
  4678.  
  4679.  
  4680.  
  4681. {────────────────────────────────────────────────────────────────────────────}
  4682.  
  4683.  
  4684.  
  4685. (*-
  4686.  
  4687. [FUNCTION]
  4688.  
  4689. Function  VSerReadPchEx(            Chan        : TSerHandle;
  4690.                                     Flags       : WORD;
  4691.                                     PchSize     : LONGINT;
  4692.                                     Pch         : PChar;
  4693.                                     TimeOut100s : LONGINT      ) : TError;
  4694.  
  4695.  
  4696. [PARAMETERS]
  4697.  
  4698. Chan        serial channel handle
  4699. flags       write flags
  4700. pchsize     maximum size of the string to read into
  4701. pch         string to read into
  4702. timeout100s timeout value
  4703. xfercount   (RETURNED) # of characters read
  4704.  
  4705. [RETURNS]
  4706.  
  4707. 0 if successfull, otherwise a serial error value.
  4708.  
  4709. [DESCRIPTION]
  4710.  
  4711. This function reads into the specified null-terimated string for up to
  4712. "pchsize" characters.
  4713.  
  4714. Flags
  4715.  
  4716.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  4717.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  4718.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  4719.   csfImmediate = $02;          { Bypass read/write buffers;              }
  4720.  
  4721. TimeOut100s is a timeout value.  If no timeout is desired, this value
  4722. should be -1.  Otherwise, this function will attempt to read into the
  4723. string until the timeout period elapses or the specified "pchsize" # of
  4724. bytes has been read.
  4725.  
  4726. XFERCOUNT is filled in by this function.  It is a count of the # of
  4727. bytes that were succesfully read into the null-terimated string.
  4728.  
  4729. This function will automatically null-terminate the string that has
  4730. been read.
  4731.  
  4732. [SEE-ALSO]
  4733.  
  4734. [EXAMPLE]
  4735.  
  4736. -*)
  4737.  
  4738.  
  4739. Function  VSerReadPchEx(            Chan        : TSerHandle;
  4740.                                     Flags       : WORD;
  4741.                                     PchSize     : LONGINT;
  4742.                                     Pch         : PChar;
  4743.                                     TimeOut100s : LONGINT      ) : TError;
  4744.  
  4745. BEGIN
  4746.  
  4747.  
  4748.   If Chan^.Sig = $CBAD Then
  4749.  
  4750.     With Chan^ Do
  4751.     BEGIN
  4752.  
  4753.       SDP.Func   := SDFReadBlock;
  4754.       SDP.Count  := Pred(PchSize);
  4755.       SDP.Buf    := Pch;
  4756.       SDP.Flags  := Flags;
  4757.       SDP.Timeout:= Timeout100s;
  4758.       SDP.Status := 0;
  4759.  
  4760.       SerDriverProc( @SDP );
  4761.  
  4762.       PByteArray( Pch )^[ Succ(SDP.Result) ] := 0;
  4763.  
  4764.       VSerReadPchEx := SDP.Error;
  4765.  
  4766.     END  { With Chan^ }
  4767.  
  4768.   Else
  4769.     VSerReadPchEx := $FBAD;
  4770.  
  4771. END;
  4772.  
  4773.  
  4774. {────────────────────────────────────────────────────────────────────────────}
  4775.  
  4776. (*-
  4777.  
  4778. [FUNCTION]
  4779.  
  4780.  
  4781. Function  VSerSetReadTimeout(       Chan        : TSerHandle;
  4782.                                     TimeOut100s : LONGINT      ) : TError;
  4783.  
  4784. [PARAMETERS]
  4785.  
  4786. Chan        serial channel handle
  4787. timeout100s default timeout value to use
  4788.  
  4789. [RETURNS]
  4790.  
  4791. 0 if successfull, otherwise a serial error value.
  4792.  
  4793. [DESCRIPTION]
  4794.  
  4795. This function sets the default timeout value that is used for the
  4796. "non-ex" read functions (IE:  VSerReadch, VSerReadBlock)
  4797.  
  4798. [SEE-ALSO]
  4799.  
  4800. [EXAMPLE]
  4801.  
  4802. Var
  4803.  
  4804.   CH : CHAR;
  4805.   Err: TError;
  4806.  
  4807. BEGIN
  4808.  
  4809.   { set the read timeout to 2 seconds (200 100s) }
  4810.  
  4811.   Err := VSerSetReadTimeout( MyChan, 200 );
  4812.  
  4813.   { the call below will now timeout after 2 seconds }
  4814.  
  4815.   Err := VSerReadCh( MyChan, Ch );
  4816.  
  4817.   { set the read timeout to 30 seconds (3000 100s) }
  4818.  
  4819.   Err := VSerSetReadTimeout( MyChan, 3000 );
  4820.  
  4821.   { the call below will now timeout after 30 seconds }
  4822.  
  4823.   Err := VSerReadCh( MyChan, Ch );
  4824.  
  4825.   { Set the read timeout to NONE }
  4826.  
  4827.   Err := VSerSetReadTimeout( MyChan, -1 );
  4828.  
  4829.   { the call below will not timeout }
  4830.  
  4831.   Err := VSerReadCh( MyChan, Ch );
  4832.  
  4833.  
  4834. END;
  4835.  
  4836.  
  4837. -*)
  4838.  
  4839. Function  VSerSetReadTimeout(       Chan        : TSerHandle;
  4840.                                     TimeOut100s : LONGINT      ) : TError;
  4841.  
  4842. BEGIN
  4843.  
  4844.   Chan^.ReadTimeOut := TimeOut100s;
  4845.  
  4846. END;
  4847.  
  4848.  
  4849. {────────────────────────────────────────────────────────────────────────────}
  4850.  
  4851.  
  4852.  
  4853. (*-
  4854.  
  4855. [FUNCTION]
  4856.  
  4857. Function  VSerSetReadFlags(         Chan        : TSerHandle;
  4858.                                     Flags       : WORD         ) : TError;
  4859.  
  4860.  
  4861. [PARAMETERS]
  4862.  
  4863. Chan        serial channel handle
  4864. flags       default write flags to use
  4865.  
  4866. [RETURNS]
  4867.  
  4868. 0 if successfull, otherwise a serial error value.
  4869.  
  4870. [DESCRIPTION]
  4871.  
  4872. This function sets the default "flags" value that is used for the
  4873. "non-ex" read functions (IE:  VSerReadch, VSerReadBlock)
  4874.  
  4875. Flags
  4876.  
  4877.   csfDefault   = $00;          { Default settings (nowait/non-immediate) }
  4878.   csfNowait    = $00;          { No wait (return if char not avail/sent) }
  4879.   csfWait      = $01;          { Wait (until char is avail / sent      ) }
  4880.   csfImmediate = $02;          { Bypass read/write buffers;              }
  4881.  
  4882.  
  4883. [SEE-ALSO]
  4884.  
  4885. [EXAMPLE]
  4886.  
  4887. Var
  4888.  
  4889.   ch : char;
  4890.   Err: TError;
  4891.  
  4892. BEGIN
  4893.  
  4894.   { set the read flags to WAIT }
  4895.  
  4896.   Err := VSerSetReadFlags( Mychan, csfWAIT );
  4897.  
  4898.   { the call below will now wait/block until the char is read }
  4899.  
  4900.   Err := VSerReadCh( MyChan, ch );
  4901.  
  4902.   { set the read flags to NOWAIT }
  4903.  
  4904.   Err := VSerSetReadFlags( Mychan, csfNOWAIT );
  4905.  
  4906.   { the call below will now return immediately if the char can not }
  4907.   { be read                                                        }
  4908.  
  4909.   Err := VSerReadCh( MyChan, Ch );
  4910.  
  4911.  
  4912. END;
  4913.  
  4914.  
  4915. -*)
  4916.  
  4917.  
  4918. Function  VSerSetReadFlags(         Chan        : TSerHandle;
  4919.                                     Flags       : WORD         ) : TError;
  4920.  
  4921. BEGIN
  4922.  
  4923.   Chan^.ReadFlags := Flags;
  4924.  
  4925. END;
  4926.  
  4927.  
  4928. {────────────────────────────────────────────────────────────────────────────}
  4929.  
  4930.  
  4931. (*-
  4932.  
  4933. [FUNCTION]
  4934.  
  4935.  
  4936. Function  VSerGetReadTimeout(       Chan        : TSerHandle   ) : LONGINT;
  4937.  
  4938.  
  4939. [PARAMETERS]
  4940.  
  4941. Chan        serial channel handle
  4942.  
  4943. [RETURNS]
  4944.  
  4945. current default timeout value,
  4946. -1 if an error occurred.
  4947.  
  4948. [DESCRIPTION]
  4949.  
  4950. This function obtains and returns the current default read timeout
  4951. value, which can be set via a call to VSerSetReadTimeout.
  4952.  
  4953. The timeout value is in 100s of a second.
  4954.  
  4955. [SEE-ALSO]
  4956.  
  4957. [EXAMPLE]
  4958.  
  4959.  
  4960.   WriteLn( 'Current timeout value ........ ',
  4961.                         VSerGetReadTimeout( MyChan ) );
  4962.  
  4963. -*)
  4964.  
  4965.  
  4966. Function  VSerGetReadTimeout(       Chan        : TSerHandle   ) : LONGINT;
  4967.  
  4968. BEGIN
  4969.  
  4970.   VSerGetReadTimeout := Chan^.ReadTimeout;
  4971.  
  4972. END;
  4973.  
  4974.  
  4975. {────────────────────────────────────────────────────────────────────────────}
  4976.  
  4977.  
  4978. (*-
  4979.  
  4980. [FUNCTION]
  4981.  
  4982. Function  VSerGetReadFlags(         Chan        : TSerHandle   ) : WORD;
  4983.  
  4984.  
  4985. [PARAMETERS]
  4986.  
  4987. Chan        serial channel handle
  4988.  
  4989. [RETURNS]
  4990.  
  4991. current default write flags.
  4992.  
  4993. [DESCRIPTION]
  4994.  
  4995. This function obtains and returns the current default read flags
  4996. value, which can be set via a call to VSerSetReadFlags.
  4997.  
  4998. The timeout value is in 100s of a second.
  4999.  
  5000. [SEE-ALSO]
  5001.  
  5002. [EXAMPLE]
  5003.  
  5004.  
  5005.   If (VSerGetReadFlags AND csfWAIT)<>0 Then
  5006.     WriteLN('Non-EX read will return if a char is unavailable')
  5007.   Else
  5008.     WriteLn('Non-EX read will wait until a char is available.');
  5009.  
  5010. -*)
  5011.  
  5012. Function  VSerGetReadFlags(         Chan        : TSerHandle   ) : WORD;
  5013.  
  5014. BEGIN
  5015.  
  5016.   VSerGetReadFlags := Chan^.ReadFlags;
  5017.  
  5018. END;
  5019.  
  5020.  
  5021.  
  5022. {────────────────────────────────────────────────────────────────────────────}
  5023.  
  5024. (*-
  5025.  
  5026. [FUNCTION]
  5027.  
  5028. Function  VSerReadCh(               Chan        : TSerHandle;
  5029.                                 Var InCh        : CHAR        ) : TError;
  5030.  
  5031.  
  5032. [PARAMETERS]
  5033.  
  5034. Chan        serial channel handle
  5035. inch        variable that will receive the character
  5036.  
  5037. [RETURNS]
  5038.  
  5039. 0 if successfull, otherwise a serial error value.
  5040.  
  5041. [DESCRIPTION]
  5042.  
  5043. This function reads a characters into the variable "inch" from the
  5044. specified serial channel "chan"
  5045.  
  5046. This function will use the default read flags and timeout values.
  5047. (As set by VSerSetReadTimeout/VSerSetReadFlags)
  5048.  
  5049. [SEE-ALSO]
  5050.  
  5051. [EXAMPLE]
  5052.  
  5053.   { read a char from the channel }
  5054.  
  5055.   Err := VSerReadCh( MyChan, Ch );
  5056.  
  5057.   { if err=0, ch is the new char }
  5058.  
  5059. -*)
  5060.  
  5061.  
  5062.  
  5063. Function  VSerReadCh(               Chan        : TSerHandle;
  5064.                                 Var InCh        : CHAR        ) : TError;
  5065.  
  5066. BEGIN
  5067.  
  5068.   VSerReadCh := VSerReadChEx( Chan,
  5069.                               Chan^.ReadFlags,
  5070.                               InCh,
  5071.                               Chan^.ReadTimeout );
  5072.  
  5073. END;
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079. {────────────────────────────────────────────────────────────────────────────}
  5080.  
  5081. (*-
  5082.  
  5083. [FUNCTION]
  5084.  
  5085. Function  VSerReadBlock(            Chan        : TSerHandle;
  5086.                                     BuffSize    : LONGINT;
  5087.                                     BuffPtr     : POINTER     ) : TError;
  5088.  
  5089. [PARAMETERS]
  5090.  
  5091. Chan        serial channel handle
  5092. buffsize    size of the block/buffer to read into
  5093. buffptr     pointer to the block/buffer to read into
  5094.  
  5095. [RETURNS]
  5096.  
  5097. 0 if successfull, otherwise a serial error value.
  5098.  
  5099. [DESCRIPTION]
  5100.  
  5101. This function reads into the specified buffer pointed to by "buffptr" from
  5102. the specified serial channel.
  5103.  
  5104. This function will use the default read flags and timeout values.
  5105. (As set by VSerSetReadTimeout/VSerSetReadFlags)
  5106.  
  5107. If an error occurs, their is no way to determine how many characters
  5108. have been read.  If you need to know have many characters are
  5109. successfully read, use the VSerReadBlockEx function.
  5110.  
  5111. [SEE-ALSO]
  5112.  
  5113. [EXAMPLE]
  5114.  
  5115. -*)
  5116.  
  5117.  
  5118. Function  VSerReadBlock(            Chan        : TSerHandle;
  5119.                                     BuffSize    : LONGINT;
  5120.                                     BuffPtr     : POINTER     ) : TError;
  5121.  
  5122.  
  5123. Var
  5124.  
  5125.   XFerCount : LONGINT;
  5126.  
  5127. BEGIN
  5128.  
  5129.   VSerReadBlock := VSerReadBlockEx( Chan,
  5130.                                     Chan^.ReadFlags,
  5131.                                     BuffSize,
  5132.                                     BuffPtr,
  5133.                                     Chan^.ReadTimeOut,
  5134.                                     XFercount           );
  5135.  
  5136. END;
  5137.  
  5138.  
  5139.  
  5140. {────────────────────────────────────────────────────────────────────────────}
  5141.  
  5142.  
  5143. (*-
  5144.  
  5145. [FUNCTION]
  5146.  
  5147. Function  VSerReadSt(               Chan        : TSerHandle;
  5148.                                     STSize      : WORD;
  5149.                                 Var St          : STRING      ) : TError;
  5150.  
  5151. [PARAMETERS]
  5152.  
  5153. Chan        serial channel handle
  5154. stsize      maximum # of chars to read into the string
  5155. st          the string to read into
  5156.  
  5157. [RETURNS]
  5158.  
  5159. 0 if successfull, otherwise a serial error value.
  5160.  
  5161. [DESCRIPTION]
  5162.  
  5163. This function reads into the specified string for up to "STsize"
  5164. characters.
  5165.  
  5166. This function will use the default read flags and timeout values.
  5167. (As set by VSerSetReadTimeout/VSerSetReadFlags)
  5168.  
  5169. [SEE-ALSO]
  5170.  
  5171. [EXAMPLE]
  5172.  
  5173. -*)
  5174.  
  5175.  
  5176.  
  5177. Function  VSerReadSt(               Chan        : TSerHandle;
  5178.                                     STSize      : WORD;
  5179.                                 Var St          : STRING      ) : TError;
  5180.  
  5181. BEGIN
  5182.  
  5183.   VSerReadSt := VSerReadStEx( Chan,
  5184.                               Chan^.ReadFlags,
  5185.                               STSize,
  5186.                               ST,
  5187.                               Chan^.ReadTimeout      );
  5188.  
  5189. END;
  5190.  
  5191.  
  5192. {────────────────────────────────────────────────────────────────────────────}
  5193.  
  5194. (*-
  5195.  
  5196. [FUNCTION]
  5197.  
  5198. Function  VSerReadPCh(              Chan        : TSerHandle;
  5199.                                     PchSize     : LONGINT;
  5200.                                     Pch         : PChar       ) : TError;
  5201.  
  5202.  
  5203. [PARAMETERS]
  5204.  
  5205. Chan        serial channel handle
  5206. Pchsize     maximum # of chars to read into the string
  5207. Pch         pointer to a null-terminated string to read into
  5208.  
  5209. [RETURNS]
  5210.  
  5211. 0 if successfull, otherwise a serial error value.
  5212.  
  5213. [DESCRIPTION]
  5214.  
  5215. This function reads into the specified null-terimated string for up to
  5216. "pchsize" characters.
  5217.  
  5218. This function will use the default read flags and timeout values.
  5219. (As set by VSerSetReadTimeout/VSerSetReadFlags)
  5220.  
  5221. If an error occurs, their is no way to determine how many characters
  5222. have been read.  If you need to know have many characters are
  5223. successfully read, use the VSerReadPchEx function.
  5224.  
  5225. [SEE-ALSO]
  5226.  
  5227. [EXAMPLE]
  5228.  
  5229. -*)
  5230.  
  5231.  
  5232.  
  5233. Function  VSerReadPCh(              Chan        : TSerHandle;
  5234.                                     PchSize     : LONGINT;
  5235.                                     Pch         : PChar       ) : TError;
  5236.  
  5237. BEGIN
  5238.  
  5239.   VSerReadPCh := VSerReadPchEx( Chan,
  5240.                                 Chan^.ReadFlags,
  5241.                                 PChSize,
  5242.                                 PCH,
  5243.                                 Chan^.ReadTimeout   );
  5244.  
  5245.  
  5246. END;
  5247.  
  5248.  
  5249. {────────────────────────────────────────────────────────────────────────────}
  5250.  
  5251. (*-
  5252.  
  5253. [FUNCTION]
  5254.  
  5255. Procedure VSerSetErrorCh(           Chan        : TSerHandle;
  5256.                                     ErrorCh     : CHAR        );
  5257.  
  5258.  
  5259. [PARAMETERS]
  5260.  
  5261. Chan        serial channel handle
  5262. errorch     character to return on errors
  5263.  
  5264. [RETURNS]
  5265.  
  5266. nothing
  5267.  
  5268. [DESCRIPTION]
  5269.  
  5270. This function sets the error character.  The error character willb
  5271. be returned by VSerGetCh when an error occurs.
  5272.  
  5273. [SEE-ALSO]
  5274.  
  5275. [EXAMPLE]
  5276.  
  5277. -*)
  5278.  
  5279.  
  5280. Procedure VSerSetErrorCh(           Chan        : TSerHandle;
  5281.                                     ErrorCh     : CHAR        );
  5282.  
  5283. BEGIN
  5284.  
  5285.   Chan^.ErrorCh := ErrorCh;
  5286.  
  5287. END;
  5288.  
  5289.  
  5290.  
  5291. {────────────────────────────────────────────────────────────────────────────}
  5292.  
  5293. (*-
  5294.  
  5295. [FUNCTION]
  5296.  
  5297. Function  VSerGetCh(                Chan        : TSerHandle  ) : CHAR;
  5298.  
  5299. [PARAMETERS]
  5300.  
  5301. Chan        serial channel handle
  5302.  
  5303. [RETURNS]
  5304.  
  5305. The newly read character.
  5306.  
  5307. [DESCRIPTION]
  5308.  
  5309. This function reads a character from the specified serial channel
  5310. and returns it.  If an error occurs, this function will return the
  5311. character set by VSerSetErrorCh.
  5312.  
  5313. [SEE-ALSO]
  5314.  
  5315. [EXAMPLE]
  5316.  
  5317.  
  5318.  
  5319. -*)
  5320.  
  5321.  
  5322. Function  VSerGetCh(                Chan        : TSerHandle  ) : CHAR;
  5323.  
  5324. Var
  5325.  
  5326.   Err : TError;
  5327.   CH  : CHAR;
  5328.  
  5329. BEGIN
  5330.  
  5331.   Err := VSerReadCh( Chan, ch );
  5332.  
  5333.   If Err<>0 Then
  5334.     VSerGetCh := Chan^.ErrorCh
  5335.   Else
  5336.     VSerGetCh := Ch;
  5337.  
  5338. END;
  5339.  
  5340.  
  5341. {────────────────────────────────────────────────────────────────────────────}
  5342.  
  5343. (*-
  5344.  
  5345. [FUNCTION]
  5346.  
  5347. Function  VSerGetStEx(              Chan        : TSerHandle;
  5348.                                     MaxBytes    : BYTE        ) : STRING;
  5349.  
  5350. [PARAMETERS]
  5351.  
  5352. Chan        serial channel handle
  5353. maxbytes    maximums # of bytes to read
  5354.  
  5355. [RETURNS]
  5356.  
  5357. The newly read string.
  5358.  
  5359. [DESCRIPTION]
  5360.  
  5361. This function reads a string from the specified serial channel
  5362. and returns it.  If an error occurs, this function will return the
  5363. an empty string.
  5364.  
  5365. [SEE-ALSO]
  5366.  
  5367. [EXAMPLE]
  5368.  
  5369. -*)
  5370.  
  5371. Function  VSerGetStEx(              Chan        : TSerHandle;
  5372.                                     MaxBytes    : BYTE        ) : STRING;
  5373.  
  5374. Var
  5375.  
  5376.   Err : TError;
  5377.   S   : STRING;
  5378.  
  5379. BEGIN
  5380.  
  5381.   Err := VSerReadSt( Chan,
  5382.                      MaxBytes,
  5383.                      S        );
  5384.  
  5385.  
  5386.   IF Err<>0 Then
  5387.     VSerGetStEx := ''
  5388.   Else
  5389.     VSerGetStEx := S;
  5390.  
  5391. END;
  5392.  
  5393.  
  5394.  
  5395. (*-
  5396.  
  5397. [FUNCTION]
  5398.  
  5399. Function  VSerGetSt(                Chan        : TSerHandle  ) : STRING;
  5400.  
  5401. [PARAMETERS]
  5402.  
  5403. Chan        serial channel handle
  5404.  
  5405. [RETURNS]
  5406.  
  5407. The newly read string.
  5408.  
  5409. [DESCRIPTION]
  5410.  
  5411. This function reads a string from the specified serial channel
  5412. and returns it.  If an error occurs, this function will return the
  5413. an empty string.
  5414.  
  5415. [SEE-ALSO]
  5416.  
  5417. [EXAMPLE]
  5418.  
  5419. -*)
  5420.  
  5421.  
  5422. Function  VSerGetSt(                Chan        : TSerHandle  ) : STRING;
  5423.  
  5424. Var
  5425.  
  5426.   Err : TError;
  5427.   S   : STRING;
  5428.  
  5429. BEGIN
  5430.  
  5431.   Err := VSerReadSt( Chan,
  5432.                      255,
  5433.                      S        );
  5434.  
  5435.  
  5436.   IF Err<>0 Then
  5437.     VSerGetSt := ''
  5438.   Else
  5439.     VSerGetSt := S;
  5440.  
  5441. END;
  5442.  
  5443. {────────────────────────────────────────────────────────────────────────────}
  5444.  
  5445.  
  5446. (*-
  5447.  
  5448. [FUNCTION]
  5449.  
  5450. Function  VSerPeekCh(               Chan        : TSerHandle;
  5451.                                 Var Ch          : CHAR          ) : TError;
  5452.  
  5453.  
  5454. [PARAMETERS]
  5455.  
  5456. Chan        serial channel handle
  5457. CH          (RETURNED) peeked character
  5458.  
  5459. [RETURNS]
  5460.  
  5461. 0 if successfull, otherwise a serial error value.
  5462.  
  5463. [DESCRIPTION]
  5464.  
  5465. This function peeks a character into the variable "inch" from the
  5466. specified serial channel "chan"
  5467.  
  5468. This function will use the default read flags and timeout values.
  5469. (As set by VSerSetReadTimeout/VSerSetReadFlags)
  5470.  
  5471. [SEE-ALSO]
  5472.  
  5473. [EXAMPLE]
  5474.  
  5475.   { read a char from the channel }
  5476.  
  5477.   Err := VSerReadCh( MyChan, Ch );
  5478.  
  5479.   { if err=0, ch is the new char }
  5480.  
  5481. -*)
  5482.  
  5483.  
  5484. Function  VSerPeekCh(               Chan        : TSerHandle;
  5485.                                 Var Ch          : CHAR          ) : TError;
  5486.  
  5487.  
  5488. BEGIN
  5489.  
  5490. END;
  5491.  
  5492.  
  5493.  
  5494. {────────────────────────────────────────────────────────────────────────────}
  5495. {────────────────────────────────────────────────────────────────────────────}
  5496. {────────────────────────────────────────────────────────────────────────────}
  5497.  
  5498. BEGIN
  5499. END.
  5500.  
  5501.  
  5502.  
  5503. {
  5504.    SERIAL PORT NOTES
  5505.    =======================================================================
  5506.  
  5507.    Data Terminal Equipment (DTE): Originates and/or receives all of
  5508.      the data (program).
  5509.  
  5510.    Data Communications Equipment (DCE): Handles the problem of transmitting
  5511.      the data from place to place (modem).
  5512.  
  5513.    Request To Send (RTS) and Clear to Send (CTS):
  5514.    ----------------------------------------------
  5515.      Terminals may not transmit until CTS is received from the DCE.
  5516.  
  5517.      Although RTS/CTS are handshaking lines, they should never be used
  5518.      as flow control because it is very likely that data will be lost.
  5519.  
  5520.    Data Set Ready (DSR) and Data Terminal Ready (DTR):
  5521.    ---------------------------------------------------
  5522.      DSR (modem ready) is used to indicate that the modem is powered on
  5523.      and is not in test mode.
  5524.  
  5525.      In RS-232D, these are called DCE Ready and DTE Ready respectively.
  5526.  
  5527.      In calling-out, DTR is used to create the equivalent of an off-hook
  5528.      condition.  When the modem is in auto-answer mode, DTR may be asserted
  5529.      in response to the ring indicator to tell the modem to answer the
  5530.      incomming call.
  5531. }
  5532.  
  5533.  
  5534. {
  5535.  
  5536.   - 840AV (DEC) [8 track built in DSP)
  5537.  
  5538.   - Fujitsu 128 3.5 MO Cartridges.
  5539.  
  5540.   - Pinnacle Micro Optical hard drive.
  5541.  
  5542.   - Secondary storage.
  5543.  
  5544.   - $600
  5545.  
  5546.   QAM   - Quantative Amplitude Modulation - Video Transfer
  5547.                      Changing amplitude modulation
  5548.                      uses amplitude to change phase.
  5549.  
  5550.   QPSK  - Quantative Phase Shift Keying Modulation -
  5551.                      Shifting phase to send data
  5552.                      (data is encoded as phase shifts)
  5553.  
  5554.  
  5555.  
  5556.  
  5557.  
  5558. }
  5559.  
  5560.  
  5561.